Making a new image from a certain area from an image

Okay the title might be vague, but what I want to achieve is the following:

- Select a rectangular area, always a fixed position and size on the image.

- Cut this selection from the original image, filling it with black colour.

- Paste this segment into a new image and add it to the data table, preferably in the same row.

Are there nodes that can do this, or would it be easier / faster to use an ImageJ macro to acomplish this?

makeRectangle(3450, 2580, 864, 654);
newImage("IMG_2644_1", "RGB black", 870, 660, 1);

Above is what I tried. However it throws an error, I think it would be due to the creation of a new image, and that KNIME doesn't know how to handle this.



makeRectangle(3450, 2580, 870, 660);
run("Auto Crop")


Now I tried this, to avoid having to duplicate the image. However I get an error:

ERROR ImageJ Macro         0:67       Error in row Row0: Interval must fit into src in SubsetViews.subsetView(...)
ERROR ImageJ Macro         0:67       Execute failed: java.lang.IllegalArgumentException: Interval must fit into src in SubsetViews.subsetView(...)


I thought this means that my rectangle doesnt fit within the image, but it does exactly. My image is sized 4320*3240.

Also I need to erase the rectangle from the original image, could we do that by just pasting an all black rectangle over it? Or is there a better way?

For rectangular crops, you can use the Image Cropper node (and define the to-be-cropped ranges by flow variables, for example).

Hi Luuklag, take a look at the attached workflow. It shows how you can cut out a  region of interest from a series of images using the interactive anotator.

I hope this helps you out.

Sounds like a good solution, but how do I enter the four numbers that define my area. I have no clue about flow variables, and haven't been able to find any decent tutorial about it either.

Thanks, this works like a charm. I'll edit it a bit however, as my ROI is always the same size and place in the image, therefore I think it would be best to keep those labelings as a saved image, and keep them constant as to improve computation time.