Can somebody explain the following code ?

1 visualización (últimos 30 días)
Sahil khandelwal
Sahil khandelwal el 21 de Mayo de 2022
Comentada: Walter Roberson el 22 de Mayo de 2022
Please explain the following code.
sout=imresize(inp,[256,256]);
t0=60;
th=t0+((max(inp(:))+min(inp(:)))./2);
for i=1:1:size(inp,1)
for j=1:1:size(inp,2)
if inp(i,j)>th
sout(i,j)=1;
else
sout(i,j)=0;
end
end
end

Respuestas (1)

dpb
dpb el 21 de Mayo de 2022
Editada: dpb el 22 de Mayo de 2022
Just turns into binary image at the threshold value, th
NB; the double loop construct in MATLAB should be written as vector logical operation and convert the result from a logical array to the same as the input array.
t0=60;
th=t0+mean([max(inp,[],'all') min(inp,[],'all']));
sout=(inp>th);
  10 comentarios
Michael Van de Graaff
Michael Van de Graaff el 22 de Mayo de 2022
why is this question tagged with 'brain-tumor'?
Walter Roberson
Walter Roberson el 22 de Mayo de 2022
The poster was providing a bit of context for the code, which is information that might potentially have helped readers understand the code better.

Iniciar sesión para comentar.

Categorías

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

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by