How to extract a matrix from the indexing data

4 vues (au cours des 30 derniers jours)
Prakash Raut
Prakash Raut le 6 Déc 2021
Commenté : Fangjun Jiang le 6 Déc 2021
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 commentaire
Walter Roberson
Walter Roberson le 6 Déc 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?

Connectez-vous pour commenter.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 6 Déc 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 commentaire
Fangjun Jiang
Fangjun Jiang le 6 Déc 2021
All the pixels not satsiying the condition be 0.
index=A>5;
B=A;
B(~index)=0

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by