I tried using imresize but it is not showing the image I sent in. The white pixels are no longer there and I just have a blank black background. Thank you.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Mai 2013

0 Stimmen

imresize(double(OriginalImage), .....)
It might be meaningful to convert back to binary afterwards.

4 Kommentare

Tola
Tola am 10 Mai 2013
Thank you.
Image Analyst
Image Analyst am 10 Mai 2013
If OriginalImage was indeed already binary, then the result of imresize will also be binary.
If you cast to double, then the output will be double, not binary, and you'll get some fractional values - it will no longer be just true and false (binary).
Walter Roberson
Walter Roberson am 10 Mai 2013
Maybe when they said "binary" they didn't mean 0's and 1's; maybe they meant it more in the sense of the data was loaded from a "binary file" instead of from a "text file". Or perhaps somehow it got to be uint8(0) and uint8(1) ?
If the original data is 0's and 1's but is not single() or double() or logical(), then applying double() to the data would work.
Tola
Tola am 11 Mai 2013
The original image is actually a binary image just that performing imresize directly on it removed the white pixels on it and gave a blank black image. But when it was converted to double and imresize done on it, it gave out the correct image in double so I just converted it back to binary. Thank you for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Josep Llobet
Josep Llobet am 6 Aug. 2021

0 Stimmen

Hi there,
Values in the resized image change to non-binary. Then, you can simply turn to binarize the image for filter the values and turn to have a binary image:
I_BW = imread("hands1-mask.png");
%class(I_BW) % <- to see the type of image
I_BW_resize = imresize(double(I_BW), 2);
%unique(I_BW_resize) % <- to see the diferent values (-0.1659, -0.1564, -0.1516...)
%size(I_BW_resize)
I_BW_resize = imbinarize(I_BW_resize);
imshowpair(I_BW, I_BW_resize, "montage");
%size(I_BW_resize)
%unique(I_BW_resize) % <- to see the diferent values (1, 0)
With the MATLAB app Image Viewer. Using the button you can see the pixel values. For call the app you can do as the example:
imtool(I_BW_resize)

Kategorien

Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by