How to extract a matrix from the indexing data

6 views (last 30 days)
Hi there,
I have a matrix A=[256*256]. Now i find all the pixels that have values greater than certain threshold using
[row, column, dataValues] = find(A > 5);
my row matrix is 11854*1 and my column matrix is also 11854*1.
Now how do i extract these rows and columns from A. I want to compare(see) two matrices(original and extracted) side by side so i want both matrices to be of same size as well. All the pixels not satsiying the condition be 0.
Thank you
  1 Comment
Walter Roberson
Walter Roberson on 6 Dec 2021
Suppose that you had an L shape that was the full height of A but half the full width of A, and suppose it was against the bottom left. Now in that scenario, what would your desired output be?
Make it simple
.++ .
.++ .
.++++ .
.++++ .
The periods are outside of the image showing the "frame".
What would you want out in this case?

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 6 Dec 2021
They can not be scaled to the same size as A. Maybe you are looking for the matrix "index" in the below example?
see help of ind2sub() or sub2ind()
B=rand(5);
index=B>0.5;
[row, column, dataValues] = find(index)
  1 Comment
Fangjun Jiang
Fangjun Jiang on 6 Dec 2021
All the pixels not satsiying the condition be 0.
index=A>5;
B=A;
B(~index)=0

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!