Understanding Image Resizing Code
Show older comments
Matlab newbie here, so please be gentle.
I am trying to port some Matlab code to C++ and am having trouble following the code that should resize an image.
What the underlying code is supposed to be trying to do is normalize line segments (which maybe/are curvy). Thus, when done each segment should have the same X length but potentially varying Y heights.
The code that is supposed to do this follows:
function func_normalize_shape(im_name )
I = imread( im_name );
if size(I, 3) > 1
for i=1:size(I,3)
a=(I(:,:,i));
if max(max(a))~=min(min(a))
I=a;
break
end
end
end
I = no_border_img(I, 1);
I = imresize( I, sqrt(200000/(size(I,1)*size(I,2))) );
I = no_border_img(I, 5);
As I understand it, the contents of the file are read into "I". The third dimension indicates how many images (in this case, I guess line segments), there are. Then, the code cycles through the images.
Here is where I start getting lost. The contents of one image are loaded into "a" (but, why an extra set of parathesis?). The clause "max(max(a))" should find the maximum number for the three dimensions of "a", then take the maximum of each that to arrive at a single number. Do the same thing for the minimum. I am losy here as to what the line "I=a" would do.
Any help on understanding this code, appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic 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!