| Re: Manipulation using where [message #53101 is a reply to message #53100] |
Wed, 21 March 2007 08:19   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Vidhya writes:
> I have an image, SUBIMAGE LONG = Array[372, 374, 62] and I
> would like to find all the values equal to zero (basically missing
> lines/rows). Right, done using
>
>
> z = where(subimage(*,*,*) EQ 0, count)
>
> The result is one-dimensional array: LONG = Array[15457]
>
> now I would like perform an operation trying to find which row there
> are in, and find the averages of the rows above and below and
> replacing them for those found zero values.
>
> How do I go about this?
>
> I tried using array_indices, but its bit confusing.
I think you are going about this in the wrong way.
If a row is missing, all the column values in that
row are zero. Thus, if you totaled your array over
the column dimension, you would find the locations
where all the columns values were zero, since these
would be zero.
Consider a simple example.
a = Indgen(4, 5, 3)
a[*,2,1] = 0
Print, a
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27
0 0 0 0
32 33 34 35
36 37 38 39
40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59
t = Total(a, 1) ; Total over columns
Print, t
6.00000 22.0000 38.0000 54.0000 70.0000
86.0000 102.000 0.000000 134.000 150.000
166.000 182.000 198.000 214.000 230.000
index = Where(t EQ 0)
rowframe = Array_Indices(Size(t,/Dim), index, /Dim)
row = rowframe[0] & frame = rowframe[1]
Print, row, frame
2 1
So, you know that all the column values in row 2, frame 1
are zero. Now you can do whatever you like with that
information. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|