% resolution_center.m
% returns the coordinates of the center of the star
% done manually by user 
% automatic detection in the commercial IE-Analyzer Software

function [centerx,centery]=resolution_center(STAR,starcut)

[h,w,d]=size(STAR);            % width and height of cropped image

ImageIN = imadjust(STAR,[0 1],[0.3 0.7]);

starcut=(starcut/100)*h;                 
rect=[0.5*w-0.5*starcut 0.5*h-0.5*starcut starcut starcut];
ImageShow=imcrop(STAR,rect);

po=figure('Name','Click into the centroid and press Enter');
imshow(ImageShow);
[centroidx,centroidy] = getpts(po);
close (po);

centerx=round(centroidx+rect(1)); 
centery=round(centroidy+rect(2));