function xss = hangsegment(parseimage, filename, blocksize2)

% to hand segment image

blocksize = blocksize2;

imageA=imread(parseimage,'png');
imageC=double(imageA);
%imageB=clean(imageC);
imageB = imageC;
a = size(imageB,1);
b = size(imageB,2);

row = a./blocksize2;
col = b./blocksize2;

initCI = zeros(row,col);

figure(1)
imagesc(imageB)
colormap(gray)
hold on

%draw grid
   for kq = 1:blocksize2:b
      plot([kq kq], [1 a],'b')
   end

   for nq = 1:blocksize2:a
      plot([1 b], [nq nq],'b')

	end

   figure(2)
   imagesc(initCI)

kinp = 0;
type = 3;

figure(1)
while (kinp ~= 4)

kinp = menu('Options', 'Image', 'Text', 'Quit');
figure(1)

switch kinp
case 1,
   type = 1
case 2,
   type = 2
case 3,
   save filename initCI
   xss = [];
   return
end

% get coordinates
figure(1)
[x,y] = ginput(2);

x = round(x);
y = round(y);

colcel = ceil(x./blocksize);
rowcel = ceil(y./blocksize);


% set type
for u = colcel(1):colcel(2)
   for uq = rowcel(1):rowcel(2)
      initCI(uq,u) = type;
   end
end


figure(2)
imagesc(initCI)
pause

figure(1)
end


xss = [];
