Hi David and Paul<br><br>Thanks for your answer ;) I really appreciate it ... I think i will work changing the factors with Paul's suggestions...<br><br>I'll try it !!<br><br><br>-------<br>RaC<br><br><br><br><div class="gmail_quote">
On Sat, Sep 26, 2009 at 11:13 PM, Paul Arner <span dir="ltr"><<a href="mailto:paularner@msn.com">paularner@msn.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
From: "Paul Arner" <<a href="mailto:paularner@msn.com" target="_blank">paularner@msn.com</a>><br>
Sent: Saturday, September 26, 2009 9:56 PM<br>
To: "David Gobbi" <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
Subject: Re: [vtkusers] Resampling an image to compare with other one<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi RaC-<br>
<br>
If I understand this correctly, you wanted to take image B (W = 120, H = 80) to image A: (W = 80, H = 120),<br>
<br>
so the x-(width) scale should be (119/79) and the y-(height) scale should be (79/119), as David argues below.<br>
<br>
>From the description, you were using (120/80) = 3/2 and (80/120) = 2/3.<br>
<br>
(B max column value is 119), so 119 * 2/3 = 79.333 ~ 79, so the width is correct, but<br>
<br>
(B max row value is 79), so 79 * 3/2 = 118.5 ~ 118, not 119 so the height is not correct, as you observed.<br>
<br>
<br>
<br>
Paul<br>
<br>
--------------------------------------------------<br>
From: "David Gobbi" <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
Sent: Saturday, September 26, 2009 8:57 PM<br>
To: <<a href="mailto:ra.corredor@gmail.com" target="_blank">ra.corredor@gmail.com</a>><br>
Cc: <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>
Subject: Re: [vtkusers] Resampling an image to compare with other one<div><div></div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi RaC,<br>
<br>
This has to do with the peculiar mathematics of image resizing. To<br>
simplify things, I'll only discuss the image widths, since the height<br>
is treated in exactly the same way.<br>
<br>
Image A has a columns in the range [0,79], and image B has columns<br>
[0,119]. In order to stretch image A to the size of image B, you need<br>
to set a magnification factor that will stretch the rightmost column<br>
of A out to the rightmost column of B. The correct factor to apply is<br>
119/79 which is 1.506329. If you feel doubtful about this, then just<br>
try it. Note that the leftmost column stays in the same place, as it<br>
should, because 0*(119/79) = 0.<br>
<br>
So if you apply a magnification factor of 2, then [0,79]*2 = [0,158]<br>
which is why vtkImageResample will give you and image that is 159<br>
pixels across.<br>
<br>
To make a long story short: when you are resizing images or doing any<br>
other sort of geometrical changes to them, you have to measure the<br>
width of the image as the distance between the leftmost pixel and the<br>
rightmost pixel, which is equal to the number of pixels subtract one.<br>
<br>
Basically, VTK does not include the "borders" of the images in its<br>
data coordinate system. In this way it is different from other<br>
coordinate systems that do include the image border, like texture<br>
coordinates. The way that VTK does coordinates is the same as medical<br>
images, e.g. like CT or MRI, while the other way is commonly used in<br>
computer graphics and digital photography.<br>
<br>
David<br>
<br>
<br>
On Sat, Sep 26, 2009 at 4:27 PM, <<a href="mailto:ra.corredor@gmail.com" target="_blank">ra.corredor@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br>
<br>
I have two images of different sizes. Image A:80x120 Image B:120x80. I must<br>
compare both in the same size, so I have to resample or resize one of the<br>
images with the size values of the other one. When I use the<br>
vtkImageResample with B, the width changes to 80, but the height to 119 !!<br>
... And when I use different factor values in the method<br>
SetAxisMagnificationFactor, I note these results:<br>
Factor Obtained Expected Height Value<br>
0,5 40 40<br>
1 80 80<br>
1,5 119 120<br>
2 159 160<br>
2,01 159 161<br>
2,1 166 168<br>
2,7 214 216<br>
3 238 240<br>
3,5 277 280<br>
4 317 320<br>
4,1 324 328<br>
So, when the factor increases, the number of pixels obtained with the<br>
SetAxisMagnificationFactor is less than the expected value.<br>
<br>
Do you know how can I resize the B image keeping the extent of the A image<br>
and not losing some rows or columns in the process??<br>
<br>
<br>
Thanks!!<br>
<br>
RaC<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
<br>
</blockquote>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote></div></div></blockquote><div><div></div><div class="h5">
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>----<br>RaC<br>