How do I invert a grayscale image and convert it to a binary image in MATLAB?

I had some trouble processing the second image you posted above. Since it's in JPEG format, the image compression seems to have made the lines and text fuzzy, and that complicates thresholding it in the way that you want I instead went back to the indexed-color GIF image you posted on the previous related question converted it to grayscale (using the function IND2GRAY from the Image Processing Toolbox ), then converted that to a reversed black and white image to match the format of the first image you posted above. Here's the code I used: X,map = imread('original_chart.

Gif'); %# Load the indexed color image img = ind2gray(X,map); %# Convert the image to grayscale reversedImage = img.

I had some trouble processing the second image you posted above. Since it's in JPEG format, the image compression seems to have made the lines and text fuzzy, and that complicates thresholding it in the way that you want. I instead went back to the indexed-color GIF image you posted on the previous related question, converted it to grayscale (using the function IND2GRAY from the Image Processing Toolbox), then converted that to a reversed black and white image to match the format of the first image you posted above.

Here's the code I used: X,map = imread('original_chart. Gif'); %# Load the indexed color image img = ind2gray(X,map); %# Convert the image to grayscale reversedImage = img.

Stackoverflow. Com/questions/2973973/… – user198729 Jun 6 '10 at 2:00.

It looks like the 3rd plot is the reverse of the 2nd above. One thing to consider is what you are using for draw image image() imagesc() or imshow() imagesc() does auto scaling and imshow() will use a color map. Another thing to consider is the input image itself.

Does it range from 0 - 255, 0 - 1.0 or RGB? Depending on what it is, the reverse would be different.

Your images aren't binary black & white. There's gray in there as well. Given from your edit that you seem to what any on pixel to be off, and any off pixel to be on (ie, convert it to a straight binary black and white image), this should do what you want: newImg = zeros(size(img)); newImg(img > 0) = 0; %.

It depends on what type your input matrix is. If it is a logical matrix you can simply use invImg = ~img; If you have scalar values in the range of 0 to n use invImg = n - img; Edit: If you want a black and white image try the following (perhaps you need to play with the level paramter): invImg = ~im2bw(img, 0.5).

– user198729 Jun 5 '10 at 15:27 1 The grids are still there. They're just very weak. – Jonas Jun 5 '10 at 19:23 1 It's because the gridlines aren't black in the white background image, they're gray.

– Donnie Jun 5 '10 at 20:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions