Re: Scale many regions in one image without using xroi [message #81657] |
Thu, 11 October 2012 08:14 |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
On Thursday, 11 October 2012 12:31:49 UTC+2, (unknown) wrote:
> I did try dilate but nothing happened; I expect I used it wrong as I didn't really
> understand it. Cold you give me an example of how it could be used in this case?
You must define a structure element to dilate with. For your case, an all one square matrix of some size might do the trick.
IDL> array = bytarr(10,10)
IDL> array[4:6,4:5] = 1
IDL> array[6,3] = 1
IDL> print, array
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 0 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
IDL> print, dilate(array, bytarr(2,2)+1B)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
IDL> print, dilate(array, bytarr(3,3)+1B)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
--
Yngvar
|
|
|
Re: Scale many regions in one image without using xroi [message #81660 is a reply to message #81657] |
Thu, 11 October 2012 03:31  |
eeaal
Messages: 4 Registered: October 2012
|
Junior Member |
|
|
On Wednesday, October 10, 2012 3:03:59 PM UTC+1, Yngvar Larsen wrote:
> On Monday, 8 October 2012 15:12:52 UTC+2, (unknown) wrote:
>
>> Hi,
>
>>
>
>
>
>> I've been searching all morning and can't find an answer to a problem
>
>> I'm having:
>
>>
>
>> I have two 2-D arrays which have clusters of 1s in an array of 0s.
>
>> I'm interested these clusters (shapes). Some of the shapes are
>
>> present in both arrays, some are missing from one or the other and in
>
>> array 2 the shapes are too small. I want to scale up the shapes in
>
>> array 2 so that the coincident shapes are the same size in both
>
>> arrays. I can use label_region to find the shapes and calculate a
>
>> correction factor. I just need a way to scale the shapes, presumably
>
>> by growing them from a central point.
>
>>
>
>> Any ideas?
>
>
>
> How about using a morphological operation like "dilate"?
>
>
>
> http://www.exelisvis.com/docs/DILATE.html
>
>
>
> (Wohooo! Finally a way to link to official documentation!)
>
>
>
> --
>
> Yngvar
Thanks Yngvar,
I did try dilate but nothing happened; I expect I used it wrong as I didn't really understand it. Cold you give me an example of how it could be used in this case?
Amb
|
|
|
Re: Scale many regions in one image without using xroi [message #81661 is a reply to message #81660] |
Thu, 11 October 2012 03:29  |
eeaal
Messages: 4 Registered: October 2012
|
Junior Member |
|
|
On Tuesday, October 9, 2012 4:20:48 PM UTC+1, Brian J. Daniel wrote:
> Without knowing all the gritty details, I suggest that given a scaling factor (xscale, yscale),
>
>
>
> s2 = size(array2)
>
> scale_array2 = Congrid(array2, s2[1]*xscale, s2[2]*yscale)
>
>
>
> Optionally, you can crop your carray2 back to the original size.
>
>
>
> new_s2 = size(scale_array2) ; new dimensions
>
> tmp = Shift(carray,-1.0*(new_s2[1]-s2[1])/2.0,-1.0*(new_s2[2]-s2[2 ])/2.0) ; shifts to new 0,0 location
>
> crop_scale_array2 = scale_array[0,s2[1]-1,0,s2[2]-1] ; crop
>
>
>
> -Brian
>
>
>
> On Monday, October 8, 2012 9:12:52 AM UTC-4, (unknown) wrote:
>
>> Hi,
>
>>
>
>>
>
>>
>
>> I've been searching all morning and can't find an answer to a problem
>
>>
>
>> I'm having:
>
>>
>
>>
>
>>
>
>> I have two 2-D arrays which have clusters of 1s in an array of 0s.
>
>>
>
>> I'm interested these clusters (shapes). Some of the shapes are
>
>>
>
>> present in both arrays, some are missing from one or the other and in
>
>>
>
>> array 2 the shapes are too small. I want to scale up the shapes in
>
>>
>
>> array 2 so that the coincident shapes are the same size in both
>
>>
>
>> arrays. I can use label_region to find the shapes and calculate a
>
>>
>
>> correction factor. I just need a way to scale the shapes, presumeably
>
>>
>
>> by growing them from a central point.
>
>>
>
>>
>
>>
>
>> Any ideas? I want to include this in a program which loops round
>
>>
>
>> hundreds of images so using XROI is not really an option...
>
>>
>
>>
>
>>
>
>> Thanks in advance.
>
>>
>
>>
>
>>
>
>> AA
Thanks Brian,
I thought of this, but if I scale up array2 so that the objects are the right size, then they will be displaced with respect to the objects in array 1. It is important that they are co-located as I am going to stack the arrays.
Unless you can tell me of a way to only scale the 1 pixels and then reposition them individually somehow?
Amb
|
|
|
Re: Scale many regions in one image without using xroi [message #81666 is a reply to message #81661] |
Wed, 10 October 2012 07:03  |
Yngvar Larsen
Messages: 134 Registered: January 2010
|
Senior Member |
|
|
On Monday, 8 October 2012 15:12:52 UTC+2, (unknown) wrote:
> Hi,
>
> I've been searching all morning and can't find an answer to a problem
> I'm having:
>
> I have two 2-D arrays which have clusters of 1s in an array of 0s.
> I'm interested these clusters (shapes). Some of the shapes are
> present in both arrays, some are missing from one or the other and in
> array 2 the shapes are too small. I want to scale up the shapes in
> array 2 so that the coincident shapes are the same size in both
> arrays. I can use label_region to find the shapes and calculate a
> correction factor. I just need a way to scale the shapes, presumably
> by growing them from a central point.
>
> Any ideas?
How about using a morphological operation like "dilate"?
http://www.exelisvis.com/docs/DILATE.html
(Wohooo! Finally a way to link to official documentation!)
--
Yngvar
|
|
|
Re: Scale many regions in one image without using xroi [message #81676 is a reply to message #81666] |
Tue, 09 October 2012 08:20  |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
Without knowing all the gritty details, I suggest that given a scaling factor (xscale, yscale),
s2 = size(array2)
scale_array2 = Congrid(array2, s2[1]*xscale, s2[2]*yscale)
Optionally, you can crop your carray2 back to the original size.
new_s2 = size(scale_array2) ; new dimensions
tmp = Shift(carray,-1.0*(new_s2[1]-s2[1])/2.0,-1.0*(new_s2[2]-s2[2 ])/2.0) ; shifts to new 0,0 location
crop_scale_array2 = scale_array[0,s2[1]-1,0,s2[2]-1] ; crop
-Brian
On Monday, October 8, 2012 9:12:52 AM UTC-4, (unknown) wrote:
> Hi,
>
>
>
> I've been searching all morning and can't find an answer to a problem
>
> I'm having:
>
>
>
> I have two 2-D arrays which have clusters of 1s in an array of 0s.
>
> I'm interested these clusters (shapes). Some of the shapes are
>
> present in both arrays, some are missing from one or the other and in
>
> array 2 the shapes are too small. I want to scale up the shapes in
>
> array 2 so that the coincident shapes are the same size in both
>
> arrays. I can use label_region to find the shapes and calculate a
>
> correction factor. I just need a way to scale the shapes, presumeably
>
> by growing them from a central point.
>
>
>
> Any ideas? I want to include this in a program which loops round
>
> hundreds of images so using XROI is not really an option...
>
>
>
> Thanks in advance.
>
>
>
> AA
|
|
|
|