Segment Cropper Background Color

Hi all,

I am using the Segment Cropper to generate cropped sub-sections of a larger image based on circular labelings. In the Segment Cropper options I choose to set the background to "Max Value of Result". What I observe is that the node always selects 255 (for unsignedbyte image) even when 255 is not the max value in the circular region. I attach one such outcome image below. Using the image Features node I calculate that the max value within the circle is 233, not 255.

It appears to pick 255 for all inputs -- as if it was incorrectly hardcoded. Is there a way to make it use the max value in the image segment as the background color? This is important for subsequent image normalization steps.

HI Joshua,

I am sorry for the misleading labeling of the option, the minimum refers to the min/max values of the image type. Which is 0 / 255 respectably, if you would convert the image to an different image type you would get a different result.

Ah, okay I understand the behavior now. Thank you.

I was able to fix the background of the segment cropper node by running the output images through a python snippet with the following code ('IMAGE_COLUMN' is the name of the column containing the image to fix):

output_table = input_table.copy()

for index, row in output_table.iterrows():
    img = row['IMAGE_COLUMNl'].array
    img[img==255] = max(img[img!=255])


This replaces all white values with the next brightest value in the image. 

1 Like

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