Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Code Block
Wiki Markup
{code}
function f = HaeKeskipisteet()
I = imread('Palikoita.bmp');
imshow(I), title('kuva');
hold on   % pitää kuvan taustalla lisättäessä siihen komponentteja
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 Block
}
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}