cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to convert matrix to (x,y,z) data set

naz_or
1-Newbie

How to convert matrix to (x,y,z) data set

Hello everybody,

I'm trying to convert matrix to (x,y,z) data set. The matrix is obtained from an image and i want to extract only certain features of that image (see mathcad file). I've menaged to do that by setting a treshold and by using binarize and scale functions. As a result matrix/image S is obtained (see mathcad file). I want to extract only those matrix elements that have value 255 and to present it as a (x,y,z) data set where x and y should correspond to index i,j of matrix S.

Indices i and j are important because they are correlated to dimensions of the flourescent screen (initial image is a snapshot of a screen) and additional mathematical operations on (i,j) i.e. (x,y) should be performed.

Thank you in advance!!!

1 ACCEPTED SOLUTION

Accepted Solutions
RichardJ
19-Tanzanite
(To:naz_or)

Is this what you are after?

View solution in original post

6 REPLIES 6

May be this help you

http://twt.mpei.ac.ru/ochkov/Mathcad-15/SolveImage.pdf

Sorry - in Russian, but you can use the google translator

And see please this picture

http://twt.mpei.ac.ru/ochkov/Sovet_MC/088/Pic_88_rus.gif

Werner_E
24-Ruby V
(To:naz_or)

I want to extract only those matrix elements that have value 255 and to present it as a (x,y,z) data set where x and y should correspond to index i,j of matrix S.

Indices i and j are important

Of course the indices would be important, as all the z values would be 255 anyway, right?

The task sure is not difficult but you would have to be more precise in respect to what way you would like the extracted data to be presented. In your matrix S there are 1008 pixels with value 255.

What should that (x,y,z) represent:

  1. a 1x3 matrix consisting of three vectors with 1008 elements? This is what Valery's programm would output. The last vector would consists of 255s only
  2. a single vector with 1008 elelement, each of which is a 1x3 matrices consisting of i, j index and 255 as third value?
  3. a 1008x3 matrix (which you would get by augmenting the three vectors from 1.)?

Writing your own small program gives you more control and its easier to modify if needed, but as you are interested in the indices only (data values would be 255 for all) you might consider using the match function. "match(255,S)" returns a vector of 1008 elements, each of which is a 2-element vector consisting of the indices of S, where the value 255 was found.

Werner_E
24-Ruby V
(To:naz_or)

Look if the attched would help.

All three possibilities I could think of incorporated

ConvertM2.png

RichardJ
19-Tanzanite
(To:naz_or)

Is this what you are after?

naz_or
1-Newbie
(To:naz_or)

Thank you guys! Richard's solution is most usable at the moment, but I am thankful for all your suggestions. I guess I'm gonna have to deal with this task a bit more, so eventually all your suggestions will be valuable for me.

Thanks again,

Goran

Werner_E
24-Ruby V
(To:naz_or)

Goran Krstic schrieb:

Thank you guys! Richard's solution is most usable at the moment, but I am thankful for all your suggestions. I guess I'm gonna have to deal with this task a bit more, so eventually all your suggestions will be valuable for me.

Thanks again,

Goran

Richard's solution is a good one, as usual - straightforeward and short.

I just noticed that I attached the picture instead of the worksheet, which could not be very helpful - sorry!

I replaced the file for the actual worksheet in the foregoing post (http://communities.ptc.com/message/198390#198390).

Werner

Top Tags