DSPRelated.com
Forums

want to understand how Matlab handle image resolution/rate conversion?

Started by kiki February 11, 2005
Hi all,

I read into the "imresize" Matlab function and want to understand how does 
these types of image transformation work...

Here is the code segment in "imresize"; it uses the "maketform" function.

I also studied that "maketform" and attached the example as follows:

Can anybody tell me what does "maketform('affine',[.5 0 0; .5 2 0; 0 0 1]);" 
mean?

Especially what does [.5 0 0; .5 2 0; 0 0 1] mean?

Second question: my understanding of "imresize" is rate conversion. Suppose 
I want to upsample to a ratio of 7/5...

In DSP principle I should first upsample by 7(fill in zeros every other 6 
pixels, and expand the size of image to x7) and then downsample by 5, with 
low pass filters in between(cutoff frequency pi/7).

However I did not see these operations in "imresize", it uses a "tformarray" 
to scale the size of the image directly to 7/5... and then use the 
"bilinear" and/or "bicubic" interpolants to connect the sample points to 
make them smoother...

I don't quite understand this procedure... why doesn't it follow the 
standard DSP rate conversion procedure?

Thanks a lot!

----------------------------------------------------
sc = (so-1)./(sn-1);% scaling for tformarray
boxA  = maketform('box',so,[0 0],so-1);
boxB  = maketform('box',sn,[0 0],sn-1);
scale = maketform('affine',diag(1./[sc 1]));

T = maketform('composite',[fliptform(boxB),scale,boxA]);

--------------------------------------------------------------------
T = maketform('affine',[.5 0 0; .5 2 0; 0 0 1]);
tformfwd([10 20],T)
I = imread('cameraman.tif');
I2 = imtransform(I,T);
imshow(I2) 


kiki wrote:
>
<snip>
> Second question: my understanding of "imresize" is rate conversion. Suppose > I want to upsample to a ratio of 7/5... > > In DSP principle I should first upsample by 7(fill in zeros every other 6 > pixels, and expand the size of image to x7) and then downsample by 5, with > low pass filters in between(cutoff frequency pi/7).
You should not confuse audio sample rate conversion with image resizing because the two have very different goals. In audio sample rate conversion the goal is to minimize the noise and distortion added during processing becasue thats what the human ear is sensitive to. For audio resampling, purely linear techniques using FIR or IIR filters are usually perferred. In image resizing, the goal is to preserve edges and minimize smearing of the image. Image resampling usually uses splines or similar. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "C++ has its place in the history of programming languages. Just as Caligula has his place in the history of the Roman Empire." -- Robert Firth