How to extract a matrix from the indexing data

4 visualizaciones (últimos 30 días)
Prakash Raut
Prakash Raut el 6 de Dic. de 2021
Comentada: Fangjun Jiang el 6 de Dic. de 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 comentario
Walter Roberson
Walter Roberson el 6 de Dic. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 6 de Dic. de 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 comentario
Fangjun Jiang
Fangjun Jiang el 6 de Dic. de 2021
All the pixels not satsiying the condition be 0.
index=A>5;
B=A;
B(~index)=0

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by