Find a range in a matrix and rescale it

4 visualizaciones (últimos 30 días)
Ben Ma
Ben Ma el 8 de Sept. de 2021
Comentada: Ben Ma el 8 de Sept. de 2021
In a image, those in the range [120 230] are scaled into range [0 120].
How to do it? Thanks.
if (a>120/255) & (a<230/255)
a==0;
end
I tried something like this but it doesnt work. Thanks.

Respuesta aceptada

KSSV
KSSV el 8 de Sept. de 2021
Editada: KSSV el 8 de Sept. de 2021
Let A be your image:
A0 = A ; % save for test
idx = A >= 120 & A<= 230 ; % get indices of required values
val = A(idx) ; % values
val_rescale = rescale(val,0,120) ; % scale the values
A(idx) = val_rescale ; % replace
  3 comentarios
KSSV
KSSV el 8 de Sept. de 2021
Typo error...val should be used in the function rescale. Edited the answer.
Ben Ma
Ben Ma el 8 de Sept. de 2021
Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by