clever way to subregion an image? [message #70388] |
Fri, 09 April 2010 09:05  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
I need to cut an image into 4 equal-size parts, which
obviously is very easy to do in a few lines.
image1 = im[0:nx/2-1, 0:ny/2-1]
image2 = im[0:nx/2-1, ny/2:*]
image3 = im[nx/2:*, 0:ny/2-1]
image4 = im[nx/2:*, ny/2:*]
i came across a way to do this with reform, but
it required 4 steps ( several reforms, a couple transposes)
to do it properly.
I'd be interested (just for fun) in a vectorized general way to do this
if any of you 'dimension jugglers' have any clever ideas,
for how to take an image and cut it into 4, or 16, or 64,
or 256 equal pieces (that would probably be about the maximum)
cheers,
bob
|
|
|
Re: clever way to subregion an image? [message #70456 is a reply to message #70388] |
Mon, 12 April 2010 11:46  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"Philip Elson" <philipelson@googlemail.com> wrote in message
news:17e370fa-592b-4441-ac6f-b70fd1ddcad4@u21g2000yqc.google groups.com...
On 9 Apr, 17:05, "R.G. Stockwell" <noem...@please.com> wrote:
> I need to cut an image into 4 equal-size parts, which
> obviously is very easy to do in a few lines.
> image1 = im[0:nx/2-1, 0:ny/2-1]
> image2 = im[0:nx/2-1, ny/2:*]
> image3 = im[nx/2:*, 0:ny/2-1]
> image4 = im[nx/2:*, ny/2:*]
>
> i came across a way to do this with reform, but
> it required 4 steps ( several reforms, a couple transposes)
> to do it properly.
>
> I'd be interested (just for fun) in a vectorized general way to do this
> if any of you 'dimension jugglers' have any clever ideas,
> for how to take an image and cut it into 4, or 16, or 64,
> or 256 equal pieces (that would probably be about the maximum)
>
> cheers,
> bob
> Use the JPEG2000 object and get this cleverness for free :-)
Thank you Philip! I was not aware that existed. I'm reading through
the documentation now, sounds great.
cheers,
bob
|
|
|
Re: clever way to subregion an image? [message #70464 is a reply to message #70388] |
Mon, 12 April 2010 04:16  |
philipelson
Messages: 9 Registered: March 2009
|
Junior Member |
|
|
On 9 Apr, 17:05, "R.G. Stockwell" <noem...@please.com> wrote:
> I need to cut an image into 4 equal-size parts, which
> obviously is very easy to do in a few lines.
> image1 = im[0:nx/2-1, 0:ny/2-1]
> image2 = im[0:nx/2-1, ny/2:*]
> image3 = im[nx/2:*, 0:ny/2-1]
> image4 = im[nx/2:*, ny/2:*]
>
> i came across a way to do this with reform, but
> it required 4 steps ( several reforms, a couple transposes)
> to do it properly.
>
> I'd be interested (just for fun) in a vectorized general way to do this
> if any of you 'dimension jugglers' have any clever ideas,
> for how to take an image and cut it into 4, or 16, or 64,
> or 256 equal pieces (that would probably be about the maximum)
>
> cheers,
> bob
Use the JPEG2000 object and get this cleverness for free :-)
|
|
|