Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
3D imresize?

Subject: 3D imresize?

From: David

Date: 17 Mar, 2009 15:11:01

Message: 1 of 12

Dear all,

I am wondering is there any available routine working on 3D matrix (image volume) in a
similar way to imresize on 2D images?

What in my mind is to apply 'imresize' to the first two dimension, then interpolate the third dimension. However, intuitively i wouldn't think this is an appropriate way to do it, since I think the output voxel should be a weighted average of its neighourhood in 3D space. (say, 6 nearest neighbour)

any suggestions? Thanks in advance.

David

Subject: 3D imresize?

From: Image Analyst

Date: 17 Mar, 2009 17:00:19

Message: 2 of 12

David:
I've wondered this also. I didn't find such a function a year ago, and as far as I know, there's still no way. You'll have to write your own. Maybe there's one on the file exchange - I don't know. Maybe the fitting webinar on Thursday could help you.

Subject: 3D imresize?

From: Ashish Uthama

Date: 18 Mar, 2009 17:40:55

Message: 3 of 12

On Tue, 17 Mar 2009 11:11:01 -0400, David <david2008.w@gmail.com> wrote:

> Dear all,
>
> I am wondering is there any available routine working on 3D matrix
> (image volume) in a
> similar way to imresize on 2D images?
>
> What in my mind is to apply 'imresize' to the first two dimension, then
> interpolate the third dimension. However, intuitively i wouldn't think
> this is an appropriate way to do it, since I think the output voxel
> should be a weighted average of its neighourhood in 3D space. (say, 6
> nearest neighbour)
>
> any suggestions? Thanks in advance.
>
> David


Just thinking aloud, if x,y,z are the three dimensions,
would it work to resize on each x-y slice first, then y-z?

looking at the picuture:
http://en.wikipedia.org/wiki/Trilinear_interpolation

Or I guess some use of TFORMARRAY might do the trick.

Subject: 3D imresize?

From: David

Date: 18 Mar, 2009 18:18:01

Message: 4 of 12

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.uqz0qhk5a5ziv5@uthamaa.dhcp.mathworks.com>...
> On Tue, 17 Mar 2009 11:11:01 -0400, David <david2008.w@gmail.com> wrote:
>
> > Dear all,
> >
> > I am wondering is there any available routine working on 3D matrix
> > (image volume) in a
> > similar way to imresize on 2D images?
> >
> > What in my mind is to apply 'imresize' to the first two dimension, then
> > interpolate the third dimension. However, intuitively i wouldn't think
> > this is an appropriate way to do it, since I think the output voxel
> > should be a weighted average of its neighourhood in 3D space. (say, 6
> > nearest neighbour)
> >
> > any suggestions? Thanks in advance.
> >
> > David
>
>
> Just thinking aloud, if x,y,z are the three dimensions,
> would it work to resize on each x-y slice first, then y-z?
>
> looking at the picuture:
> http://en.wikipedia.org/wiki/Trilinear_interpolation
>
> Or I guess some use of TFORMARRAY might do the trick.

Ashish,

Thanks for your reply.

resize on each x-y slice first, then y-z
I think there might be some problems by performing the 'imresize' process separately. For instance, If I 'resize' the original image volume by a factor of 0.5 (i.e., 'downsampling' the original volume by a factor of two) Ideally, the resized image should contains half information along the three direction. If we resize the XY slice, and then YZ, the second 'imresize' does not exactly halving the informaion.

Or I guess some use of TFORMARRAY might do the trick.
I agree that the trick can hopefully be solved by using TFORMARRAY,

Subject: 3D imresize?

From: Ashish Uthama

Date: 18 Mar, 2009 18:26:15

Message: 5 of 12

On Wed, 18 Mar 2009 14:18:01 -0400, David <david2008.w@gmail.com> wrote:

> "Ashish Uthama" <first.last@mathworks.com> wrote in message
> <op.uqz0qhk5a5ziv5@uthamaa.dhcp.mathworks.com>...
>> On Tue, 17 Mar 2009 11:11:01 -0400, David <david2008.w@gmail.com>
>> wrote:
>>
>> > Dear all,
>> >
>> > I am wondering is there any available routine working on 3D matrix
>> > (image volume) in a
>> > similar way to imresize on 2D images?
>> >
>> > What in my mind is to apply 'imresize' to the first two dimension,
>> then
>> > interpolate the third dimension. However, intuitively i wouldn't think
>> > this is an appropriate way to do it, since I think the output voxel
>> > should be a weighted average of its neighourhood in 3D space. (say, 6
>> > nearest neighbour)
>> >
>> > any suggestions? Thanks in advance.
>> >
>> > David
>>
>>
>> Just thinking aloud, if x,y,z are the three dimensions,
>> would it work to resize on each x-y slice first, then y-z?
>>
>> looking at the picuture:
>> http://en.wikipedia.org/wiki/Trilinear_interpolation
>>
>> Or I guess some use of TFORMARRAY might do the trick.
>
> Ashish,
>
> Thanks for your reply.
>
> resize on each x-y slice first, then y-z
> I think there might be some problems by performing the 'imresize'
> process separately. For instance, If I 'resize' the original image
> volume by a factor of 0.5 (i.e., 'downsampling' the original volume by a
> factor of two) Ideally, the resized image should contains half
> information along the three direction. If we resize the XY slice, and
> then YZ, the second 'imresize' does not exactly halving the informaion.
>
> Or I guess some use of TFORMARRAY might do the trick.
> I agree that the trick can hopefully be solved by using TFORMARRAY,


Ah yes, The IMRESIZE would reduce y twice.

How about something like DECIMATE along each dimension one after the
other? %beat an idea till it dies :D
Might not be efficient though, let us know if you figure out TFORMARRAY.

Subject: 3D imresize?

From: Robert

Date: 18 Mar, 2009 19:07:01

Message: 6 of 12

Guys,

Have a look for Gaussian pryamids, there is the code on here, that will do what you want.

Bob

Subject: 3D imresize?

From: Steve Eddins

Date: 19 Mar, 2009 12:17:33

Message: 7 of 12

David wrote:
> "Ashish Uthama" <first.last@mathworks.com> wrote in message <op.uqz0qhk5a5ziv5@uthamaa.dhcp.mathworks.com>...
>> On Tue, 17 Mar 2009 11:11:01 -0400, David <david2008.w@gmail.com> wrote:
>>
>>> Dear all,
>>>
>>> I am wondering is there any available routine working on 3D matrix
>>> (image volume) in a
>>> similar way to imresize on 2D images?
>>>
>>> What in my mind is to apply 'imresize' to the first two dimension, then
>>> interpolate the third dimension. However, intuitively i wouldn't think
>>> this is an appropriate way to do it, since I think the output voxel
>>> should be a weighted average of its neighourhood in 3D space. (say, 6
>>> nearest neighbour)
>>>
>>> any suggestions? Thanks in advance.
>>>
>>> David
>>
>> Just thinking aloud, if x,y,z are the three dimensions,
>> would it work to resize on each x-y slice first, then y-z?
>>
>> looking at the picuture:
>> http://en.wikipedia.org/wiki/Trilinear_interpolation
>>
>> Or I guess some use of TFORMARRAY might do the trick.
>
> Ashish,
>
> Thanks for your reply.
>
> resize on each x-y slice first, then y-z
> I think there might be some problems by performing the 'imresize' process separately. For instance, If I 'resize' the original image volume by a factor of 0.5 (i.e., 'downsampling' the original volume by a factor of two) Ideally, the resized image should contains half information along the three direction. If we resize the XY slice, and then YZ, the second 'imresize' does not exactly halving the informaion.
>
> Or I guess some use of TFORMARRAY might do the trick.
> I agree that the trick can hopefully be solved by using TFORMARRAY,

David,

If you're willing to start with imresize.m and do some custom coding,
take a look at the resizeAlongDim subfunction in imresize.m.

You can use TFORMARRAY, too, although it will not do the antialiasing
that imresize does.

---
Steve Eddins
http://blogs.mathworks.com/steve/

Subject: 3D imresize?

From: David

Date: 19 Mar, 2009 13:04:01

Message: 8 of 12

Thanks for replies, guys,

I will try to resize the image by Gaussian Pyramid method, (http://www.mathworks.com/matlabcentral/fileexchange/12037)

also, I will go through the sub-function of imresize.m.

Subject: 3D imresize?

From: Dave Brackett

Date: 10 Feb, 2011 15:18:04

Message: 9 of 12

"David" wrote in message <gptfs1$3ro$1@fred.mathworks.com>...
> Thanks for replies, guys,
>
> I will try to resize the image by Gaussian Pyramid method, (http://www.mathworks.com/matlabcentral/fileexchange/12037)
>
> also, I will go through the sub-function of imresize.m.


Hi, did you modify the sub function of imresize to handle the 3rd dimension? I am interested in doing this too as gaussian pyramids are a bit limiting.

Thanks.

Subject: 3D imresize?

From: Domingos Domingos

Date: 18 Aug, 2011 23:55:10

Message: 10 of 12

"Dave Brackett" wrote in message <ij0vjc$21o$1@fred.mathworks.com>...
> "David" wrote in message <gptfs1$3ro$1@fred.mathworks.com>...
> > Thanks for replies, guys,
> >
> > I will try to resize the image by Gaussian Pyramid method, (http://www.mathworks.com/matlabcentral/fileexchange/12037)
> >
> > also, I will go through the sub-function of imresize.m.
>
>
> Hi, did you modify the sub function of imresize to handle the 3rd dimension? I am interested in doing this too as gaussian pyramids are a bit limiting.
>
> Thanks.

Guys,

were you able to code a 3D imresize?

Many thanks,
João

Subject: 3D imresize?

From: Dave Brackett

Date: 19 Aug, 2011 08:21:09

Message: 11 of 12

"Domingos Domingos" <joao.sousa.domingos@gmail.com> wrote in message <j2k8ou$op2$1@newscl01ah.mathworks.com>...
> "Dave Brackett" wrote in message <ij0vjc$21o$1@fred.mathworks.com>...
> > "David" wrote in message <gptfs1$3ro$1@fred.mathworks.com>...
> > > Thanks for replies, guys,
> > >
> > > I will try to resize the image by Gaussian Pyramid method, (http://www.mathworks.com/matlabcentral/fileexchange/12037)
> > >
> > > also, I will go through the sub-function of imresize.m.
> >
> >
> > Hi, did you modify the sub function of imresize to handle the 3rd dimension? I am interested in doing this too as gaussian pyramids are a bit limiting.
> >
> > Thanks.
>
> Guys,
>
> were you able to code a 3D imresize?
>
> Many thanks,
> João

Hi, I found this on the fileexchange which worked ok for me:
http://www.mathworks.com/matlabcentral/fileexchange/26385-resize-any-arrays-and-images
It can resize any arrays incl. 3d.

Hope that helps.

Subject: 3D imresize?

From: Matt J

Date: 19 Aug, 2011 08:28:09

Message: 12 of 12

"Domingos Domingos" <joao.sousa.domingos@gmail.com> wrote in message <j2k8ou$op2$1@newscl01ah.mathworks.com>...
>
>
> were you able to code a 3D imresize?
=========================

You can easily IMRESIZE for any dimension by recycling some techniques from this thread from a few days ago

http://www.mathworks.com/matlabcentral/newsreader/view_thread/160291#849509

and incorporating it with this FEX tool,

http://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-manipulation

The following shows this for an NxNxN array, but it is straightforward to modify this for non-cubic arrays. I leave it as an exercise.

 %example input data
resizeFactor=4/3;
inputArray=rand(100,100,100);

dInterval=1./resizeFactor;
maxVal=size(inputArray,1);

xi = 1:dInterval:maxVal;
j1 = floor(xi);
j2 = j1+1;
w1 = j2-xi;
w2 = 1-w1;
j2(end) = maxVal;
m = length(xi);
n = maxVal;
S = sparse([1:m 1:m], [j1 j2], [w1 w2], m, n); %resize matrix for 1 dimension

result = KronProd({S},[1,1,1])*inputArray;

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us