Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Wiki Markup

{code}
Code Block
function f = HaeKeskipisteet()
I = imread('Palikoita.bmp');
imshow(I), title('kuva');
hold on
L = bwlabel(I);%numeroi alueet
Ominaisuus2 = regionprops(I,'all')
Maara=max(L(:))%hae kpl määrä kuvasta
for i=1:Maara
    Keskipiste=Ominaisuus2(i).Centroid
    plot(Keskipiste(1),Keskipiste(2),'X')
  %plot(Keskipiste,'Z')
end
hold off
{code}
Ja sitten vaikeampi tapa

...


{code
}
function f = HaePalikka()
I = imread('Palikoita.bmp');
figure, imshow(I), title('Palikka.bmp');
hold on
[rows,cols] = size(I)
x = ones(rows,1)*[1:cols]; % Matriisi x with each pixel set to its x coordinate
y = [1:rows]'*ones(1,cols)
area = sum(sum(I));
meanx = sum(sum(double(I).*x))/area
meany = sum(sum(double(I).*y))/area
%Segout=Segout  
imshow(I), title('kuva ja keskipiste'),;
plot(meanx,meany,'X')
hold off
{code}