Message Boards Message Boards

1
|
3165 Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Binarizing images of similar background and object color?

Posted 2 years ago

As shown in the example picture below, if the background and the color of the object to be obtained are similar, What would be good to use as a preprocessing before proceeding with binarization?

i = Blur[img, 3];
res = ImageMultiply[i, 
   SelectComponents[FillingTransform@Binarize[i], "Area", -1]];

I used the code below, but it's hard to separate.

What is the pre-processing method for neat binarization?

GraphicsRow[{i, res}]

enter image description here

POSTED BY: Arim Gwon
9 Replies

Hi Arim

Not sure about your question, but you can use

ColorNegate[ ]

in case you just want to reverse black/white. Otherwise you need to be more specific, example, ...

Robert

POSTED BY: Robert Nowak

Oh, thank you so much! :)

POSTED BY: Arim Gwon
img // With[{r = 3}, (Closing[#, 10 r] &)@*(Opening[#1, 2 r] &)@*(GradientFilter[#, 6 r] &)] // Binarize // img # &

I am afraid that it will be very difficult to process similar images with the same set of filter parameters. So far the parameters are just a result of trial & error.

Robert

POSTED BY: Robert Nowak

If you use it in a similar image, let's adjust the parameters! Thank you for your advice.

POSTED BY: Arim Gwon

Hello, Is it possible for an additional binarized image to reverse the current object with a white background? (The object is black background of white)

POSTED BY: Arim Gwon

Hi, if you want the original image without background then just multiply with the binary mask.

POSTED BY: Robert Nowak

Do you mean that if you want to show only binarized objects without background, you just need to multiply the above equation by binarized masks?

and.. How could you find the optimal numbers for r=3, 10r, 2r, 6r, etc. in the equation presented? I want to apply it to other similar pictures.

Thanks,,

POSTED BY: Arim Gwon

Hi Arim

img // With[{r = 3}, (Closing[#, 10 r] &)@*(Opening[#1, 2 r] &)@*(GradientFilter[#, 6 r] &)] // Binarize

Robert

POSTED BY: Robert Nowak

I think the object and background are completely binarized. Thank you for your help!

POSTED BY: Arim Gwon
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract