Resizing a binary image issue
Show older comments
Hello. I am trying to resize a binary image to match the dimensions of another workspace matrix. Yet I am losing the non-zero values in the new, resized matrix. I have attached the binary image ("BW_05052021.png") that serves as a mask.
%The value of the BW image is 10000 x 8082 logical
%Looking to resize the image matrix to 142 x 128, not worried about maintaining scalar ratio
nnz(BW); % ans = 952
BW_resize = imresize(BW, [142 128]); % Resizing BW to the specified dimensions; 142 rows and 128 columns
nnz(BW_resize); % ans = 0 and not sure why
If needed, I can clarify or provide additional information as needed. Thank you!
1 Comment
Atsushi Ueno
on 5 May 2021
It looks like the original image is lost because the ratio of resizing is too high. If you compare the original image with images that have been reduced to 75%, 50%, and 25%, you can see the limit of the reduction ratio at which the original image can be recognized. You may need gray-scale image for your requirement.
Accepted Answer
More Answers (1)
Image Analyst
on 5 May 2021
Edited: Image Analyst
on 5 May 2021
To resize an image to match the size of another image, use imresize():
newImage2 = imresize(originalImage2, size(image1));
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
