Message Boards Message Boards

Binarize (thresholding) and inverse thresholding with values from 0 to 255?

GROUPS:

Dear Friends I need your help regarding image analysis. 1. I require achieving the binarize (thresholding) and inverse thresholding in Mathematica with values from 0 to 255 whereas, as I have learn so far, binarization in Mathematica occurs only in the region of 0 to 1. Below I did in AdobePhotoshop and next Figures are my attempts in Mathematica. 2. As noticed I tried to use Manipulate with binarize which work but same attempt with ColorNegate gives error. Please clarify same. 3. Eventually, I need to calculate the Pixel values of the visible region. I want to develop a small app, which can import the images and do so with Manipulate.

POSTED BY: Man Oj
Answer
10 days ago

In Mathematica, image data processing is generally performed on real numbers, as your experience with Binarize shows. However, you can get 8 bit data by specifying "Byte" in the ImageData function. Example:

In[46]:= ImageData[im=Binarize[RandomImage[1, {4, 4}], 0.2], "Byte"]
Out[46]= {{255,0,255,255},{255,0,255,0},{255,255,255,255},{0,0,255,0}}

What is the problem you saw with ColorNegate? Continuing this example,

In[48]:= ImageData[ColorNegate[im],"Byte"]
Out[48]= {{0,255,0,0},{0,255,0,255},{0,0,0,0},{255,255,0,255}}

shows that ColorNegate is working fine on the binary image. What did you try?

Can you clarify question 3? What you describe should be very easy to do in Mathematica, but I'm not sure what you mean.

POSTED BY: Chad Knutson
Answer
10 days ago

Hi, Thanks for feedback. Iam getting following also having errors when using color negate with manipulate, i,e, not able to use manipulate with colorNegate. Error on color negate Error on color negate2

Attachment

Attachment

POSTED BY: Man Oj
Answer
9 days ago

The red text is suggesting that there is a problem with your input. And the error message is also telling you important information. Namely, ColorNegate only takes a single argument. The way you have written it, the 2nd argument to ColorNegate is {y,0,1}. Try this:

Manipulate[ColorNegate[Binarize[RandomImage[],y]],{y,0,1}]

Here in Community, the {y,0,1} part looks blue to me. In Mathematica 11, if will be an aqua-ish color, indicating that y is the dynamic symbol for the Manipulate expression.

FillingTransform[ColorNegate[Binarize[RandomImage[], .1]]]
POSTED BY: Chad Knutson
Answer
9 days ago

Group Abstract Group Abstract