function [Tops, im2,rotIm,LD,PH,LH,PD,ang] = ImageProcessing(app,pathToImage)
    im = imread(pathToImage);
   % im = undistortImage(im, app.IntristicsParams);
    [centers,LH,LD,PH,PD] = findCircles(im);
    if (isempty(LH) || isempty(LD) ||isempty(PH) ||isempty(PD))
        [LH,LD,PD,PH] = nalezeniZbyvajicihoBodu(centers, im,LH,LD,PD,PH);
    end
   [rotIm, LH,PH,LD, PD,ang] = rotateImage(im, LH,PH,LD, PD);
    %rotIm = im;
    app.OrangePoints = [LD;PH;LH;PD];
    Width = round(sqrt((PH(1)-LH(1))^2 + (PH(2)-LH(2))^2));    %šířka, vzdálenost bodů
    Heigh = round(sqrt((LD(1)-LH(1))^2 + (LD(2)-LH(2))^2));    %výška
    %im2 = imcrop(rotIm,[LH(1)-30,LH(2)-150,round(width+30),round((Heigh+50)/1.8)]);
    im2 = imcrop(rotIm,[LH(1)+20,LH(2)-50,Width-40,round((Heigh+50)/1.8)]);
    im2BW = Preprocessing(im2);
    [startingPoint,MaxNumOfStcks] = whereToStart(im2BW);
    Tops = findTops(im2BW,startingPoint,MaxNumOfStcks,im2);
    Tops = findWrongTopsAutoGUI(Tops,1);
end