Feed the "Image Cropper" with variables

Hi all


I want to feed variables into the Image Cropper node, but I got stuck. The idea is to crop parts of an existing image, e.g. x * y with  [1-100]*[1-100], but I do not know which flow variable should be used for this. Any idea? The workflow is attached.

The background is the following: At the end I want to build a loop to crop specific parts of the image.






Hi Frank,

unfortunately, the Cropper has its own (very limited) User-Interface. Therefore you can't really configure the Cropper using Flow Variables, yet. Anyway, I created an example workflow which demonstrates how you can "easily" create a masked image. The workflow needs of course some more polishing, but when you have the mask, you can use the SegmentCropper to crop the individual parts of your image.

I hope this helps,


Hi Christian

I adapted your workflow to generate a mask with 10*10 segments of size 100*100 and used this mask to crop a RGB image. Before cropping the RGB images I splitted it into the three channels.

The "Segment Cropper" with Option "Image Column" = <none> creates a white bittype image, with option "Image Column" = column with IMGplus image creates an empty table.

A bittype image does not make sense for my problem because I want to split the original image into several parts. Any idea? See my attached workflow.


Your "mask" imags has to not the same dimensionality as the other image. You should adapt the workflow and the parametres (also in the java snippets) in the mask creation.

PS: In this "workaround" workflow, the dimensiony of mask / image have to match. It would be relatively easy to write a small JavaSnippet or IMAGEJ2 Snippet which does exactly what you want. But this functionality (snippets with image data) will be available only with the new 1.3.0 release end of the year.


It was already my fear that the mask is of different size.

For my specific problem all images are of the same size so that I can adapt the workflow.

Thanks for clarification!




I think I have the same problem.

I have a table with in one row an RGB image and a Mask that has only 1 channel, R. Now the image cropper won't function as the dimentions are not equal. How could this be fixed?

Hi Luuklag,

Did you try the "Segment Cropper" to crop out the segments? What exactly do you want to achieve?

Img (RGG) +  Labeling -> ?




Yes I used the segment cropper, thought this topic was about that, sorry. However I have a mask and the image it comes from, and I want to take the area of the mask from the original image to feed it into OCR, as feeding the OCR with the entire image doesn't produce propper results.

Ah, isn't der an option like "expand virtually" in the segment cropper? This means, if the dimensionality of the labeling is lower  than the source image, the labeling gets expanded.

I couldn't find that option.

you could use the splitter, then a column loop start / loop end and then a merger again. but this is way too complicated for what you need. I will try to figure something out and let you know tomorrow!


I made a counting loop now, to reproduce the segment three times. However I can't merge that into 1 image again. As the image merger won't take segments as input.

Awesome. Sorry I couldn't find a better solution since now. but its on my list. In the other thread I already mentoined the node tutorials for "GroupBy" and "LabelingFilter" on the Example Server (099_CommunityContributions/ImageProcessing/Tutorials). There you learn how to reproduce Segmentations/Labelings from tables.

Thanks a lot

Well I didn't find a solution. But I did further investigate the problem.

The original image I open has the following properties:

- no Dimensions: 3 ; Axes: X;Y;Channel

My segment has the following properties

- no Dimesions: 2 ; Axes: X;Y

For some reason this diference makes the segment cropper fail. Now I can't figure out how to add a dimention to my segmented image. I do have a table with 3 times the same image, now I need to convert that table to an RGB image I guess. But when I do that it has become an image, and it is no longer a segment, so that I can't feed the segment cropper anymore.

I found a work around.

I used the labeling to RGB node followed by again connected component analysis. The first node created me the dimension Channel again I needed for the segment cropper. The second node converted the image back into a segment I needed for the segment cropper.


Edit: the only downside is now that I have 3 times the template. I prefer to have only one come up instead of filtereing one out, as to speed up computation.

You can add dimensions using the "Dimension Extender". But I see that these are just workarounds for workarounds. In the end you would like to Crop 3-Channels given a Single Channel Labeling, right?


Yes. I want to crop an RGB (3 channels) with just a label. Perhaps you can code it that if the label has fewer dimentions it will just duplicate over the channels.

I also tried the dimension extender, but didn't really get that to work properly. But that probably would be a better way, as it probably takes less computing then doing a new CCA. Using the dimension extender I got the following warning: WARN  Dimension Extender   2:40       No columns of type ImgPlusValue available!

Edit: Perhaps the quickest "fix" would be to allow the dimension extender to take also other file types besides ImgPlusValue