0

como encontrar valores de threshold em uma imagem, com os seguintes intervalos: 0-0,25, 0,25-0,50,0,50-0,75 e 0,75-1? E poderiam dizer-me o que faz o seguinte código por favor:

GRAY = mat2gray(bEnhanced);
% figure,
% imshow(GRAY),
% title('Gray Image');
threshold = graythresh(GRAY);
disp(threshold)
threshold
BW = imbinarize(GRAY, threshold*(1.1+threshold));
c = BW;
% figure,
% imshow(BW),
% title('Binary Image');
BW = ~ BW;
% figure,
% imshow(BW),
% title('Inverted Binary Image');
[B,L] = bwboundaries(BW,'holes');
STATS = regionprops(L, 'all'); % we need 'BoundingBox' and 'Extent'
% pixelVals = regionprops(c,'MeanIntensity');
% Step 7: Classify Shapes according to properties
% Square = 3 = (1 + 2) = (X=Y + Extent = 1)
% Rectangular = 2 = (0 + 2) = (only Extent = 1)
% Circle = 1 = (1 + 0) = (X=Y , Extent < 1)
% UNKNOWN = 0
% figure,
% imshow(RGB),
% title('Results');
im=bEnhanced;
pixelVals=regionprops(L,im,'MeanIntensity');
axes(handles.img_bw);
imshow(GRAY);
hold on
for i = 2 : length(STATS) %ignore idx=1, because that's the whole image
%   W(i) = uint8(abs(STATS(i).BoundingBox(3))>4 && abs(STATS(i).BoundingBox(4)) > 4);
%   W(i) = W(i) + 2 * uint8((STATS(i).Extent - 1) == 0 );
  centroid = STATS(i).Centroid;
    if(abs(STATS(i).BoundingBox(3))>8 && abs(STATS(i).BoundingBox(4)) >8) 
    plot(centroid(1),centroid(2),'wX','Color', 'red');
  bb = STATS(i).BoundingBox;
      rectangle('Position', bb,...
          'EdgeColor', 'red', 'LineWidth', 1)
  %   visboundaries(B,'LineWidth',0.1);
  %   pixelVals(i).MeanIntensity
  density = ((pixelVals(i).MeanIntensity*100)/255);
  t = text(centroid(1),centroid(2),strcat(num2str(density)),'Color','red');
   %t = text(centroid(1),centroid(2),strcat(num2str(density),'% ----- ' , num2str(i)),'Color','black');
    t.FontSize = 15;
    end
end
hold on
img=getimage(handles.img_gray);
hold off
5
  • Nosso idioma é o Português. Traduza sua pergunta.
    – user28595
    15/09/2018 às 22:55
  • como encontrar valores de threshold em uma imagem, com os seguintes intervalos: 0-0,25, 0,25-0,50,0,50-0,75 e 0,75-1? E poderiam dizer-me o que faz o seguinte código por favor 15/09/2018 às 23:05
  • Catarina, clique em EDITAR e traduza a pergunta. Deixar em ingles e comentar aqui náo resolve e sua pergunta ainda pode ser fechada.
    – user28595
    15/09/2018 às 23:17
  • Faltou traduzir o titulo tambem
    – user28595
    15/09/2018 às 23:18
  • Ok,obrigado, sou nova aqui e não sabia :/ 15/09/2018 às 23:19

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .