How to extract a matrix from the indexing data

4 Ansichten (letzte 30 Tage)
Prakash Raut
Prakash Raut am 6 Dez. 2021
Kommentiert: Fangjun Jiang am 6 Dez. 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 Kommentar
Walter Roberson
Walter Roberson am 6 Dez. 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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 6 Dez. 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)

Community Treasure Hunt

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

Start Hunting!

Translated by