function f = HaePalikka()
I = imread('Palikoita.bmp');
figure, imshow(I), title('Palikka.bmp');
\[x,y,z\] = size(I); % Checking whether the picture is colored or
%monochromatic, if colored then converting to gray.
%I=RGB2GRAY(I);
%BWs = edge(I, 'sobel', (graythresh(I) * .1));
%figure, imshow(BWs), title('binary gradient mask');
%selvitä strel komennon toiminta
%se90 = strel('line', 3, 90);
%se0 = strel('line', 3, 0);
%BWsdil = imdilate(BWs, \[se90 se0\]);
%figure,
%imshow(BWsdil), title('dilated gradient mask');
%BWdfill = imfill(BWsdil, 'holes');
%figure,
%imshow(BWdfill);
%title('binary image with filled holes');
%BWnobord = imclearborder(BWdfill, 4);
%figure,
%imshow(BWnobord), title('cleared border image');
%seD = strel('diamond',5);
%BWfinal = imerode(BWnobord,seD);
%BWfinal = imerode(BWfinal,seD);
%figure,
%imshow(BWfinal), title('segmented image');
%BWoutline = bwperim(BWfinal);
%imshow(BWoutline), title('kuva ulkoreunoista');
%Segout = I;
%Segout(BWoutline) = 255;
%figure,
hold on
%imshow(Segout), title('outlined original image');
%pic=I
%pic=BWfinal
%\[x,y,z\] = size(pic); % Checking whether the picture is colored or monochromatic, if colored then converting to gray.
%if(z==1)
;
%else
% pic = rgb2gray(pic);
%end
%im = pic;
\[rows,cols\] = size(I)
x = ones(rows,1)*\[1:cols\]; % Matrix with each pixel set to its x coordinate
y = \[1:rows\]'*ones(1,cols); % " " " " " " " y "
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
|