X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Apr 2011 06:28 PM by  anon
How to create new matrix based on specific condition
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
07 Apr 2011 06:28 PM
    Hi all, I have ten images, I guess it also means 10 matrixes. I want to apply a "IF" condition to those matrixes for each pixel. And finally I want to generate a new matrix which based on the 'IF' condition. Specific, if the the pixel located at Row:5, Col:12 of original matrix_3(the third original matrix) match the "IF"condition. Then the value of Row_5 Col_12 of output matrix is 3. I'm not sure whether I describe the problem clearly. Thanks for your kindly help.

    Deleted User



    New Member


    Posts:
    New Member


    --
    08 Apr 2011 02:28 AM
    One way it would be to use the WHERE function to find all the pixels that match your condition. Conider following example that prepares a mask based on given condition: matrix = dist(5); condIdx = WHERE(matrix gt 2); t mask = INTARR(5,5); mask[condIdx] = 1; print, matrix; print, mask; However this would mean that you have to stack your images into a 3D array. This could cause some memory problems when the images are large.
    You are not authorized to post a reply.