X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12 Mar 2007 04:04 PM by  anon
Change 640x240 array into 320x240 array using pixel values
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
12 Mar 2007 04:04 PM
    I have this 640x240 array i need to change into a 320x240 array. However, i need to use th info of the first array, values of the pixels and compute them together to be able to obtain value for pixels in the second array (values of 2 pixels correspond to 1 pixel in the 2nd, hence double width). Is there an easy straightforward way of doing this without resorting to too many for loops. thanks radha

    Deleted User



    New Member


    Posts:
    New Member


    --
    12 Mar 2007 04:04 PM
    Let me demonstrate this with an example. Let's call each row of the 640 x 240 array a "scanline", and let's say that you want to take each even-numbered element of each scanline and combine it mathematically with the odd-numbered element that follows it. Thus, element 0 and element 1 on any given scanline will combine to produce some single value that will be element 0 in the 320 element result scanline, elements 2 and 3 will produce element 1 in the result scanline, 4 and 5 will produce element 3 in the result scanline, etc. Let us pretend that the input array is a byte array, that the operation will be multiply even-numbered byte by 256 and add to it its odd-numbered neighbor. The output array would then be a short integer array. The way, then, to produce the output array without having to resort to loops is to copy out of the original array to one new array all the values that are in even-numbered subscripts, copy to another new array all the values that are in odd-numbered subscripts. You will then end up with two arrays with the same dimension that can be easily mathematically combined in one line of code. IDL has an easy way to do this even-numbered and odd-numbered subscript copying. Here is the example that demonstrates the syntax: origArr = bindgen(640, 240) ; Keeps sequentially wrapping values 0B to 255B ; convert to short int for subsequent math operation evenSubscriptArr = fix(origArr[0:638:2, *]) oddSubscriptArr = fix(origArr[1:639:2, *]) resultArr = (evenSubscriptArr * 256) + oddSubscriptArr That should be all you need to produce a 16-bit 320 x 240 result array that uses all the elements of your original array as you wanted. James Jones
    You are not authorized to post a reply.