Image manipulation, cut out a non regular shape from an image

Hi All

I have some images that have areas of interest in that are trapezoid in shape (4 sides, kind of like a pyramid with the top chopped off). Can anyone suggest a way of cutting these shapes out of my image to create a new image? I have looked at node-red-contrib-image-tools but as far as I can see that only allows you to crop an image down to a square.

Thanks

Raster images are always square/rectangular. It is the use of transparency that gives them irregular shape.

So you can use image-tools to apply a mask or manipulate the pixels to make a "cut out" and save it in a format that supports transparency (e.g. png)

thanks for the reply.

Yes, I was looking at trying to mask the areas of the image. The mask option that I looked at in node-red-contrib-image-tools required another image to use as a mask. I did try and create a new image and was then going to draw triangles on it to use as a mask but I couldn't see any way of drawing on a new blank image.

Any guidance on how I could mask off triangular areas of the image using just node-red and not using existing images to mask would be much appreciated.

Am I correct in thinking that you are the author of the image-tools node?

Yes.

Been some time since I played with image stuff so would need some thought. One solution that jumps out is to scan the image and set pixels transparent. Another would be to dynamically build a mask and apply that.

One last idea, moving away from image-tools is to import node-canvas into a function node (via the setup tab) and use the canvas path to draw an irregular shape and clip it. I have an example somewhere & will post it if I can find it.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.