function [ImgOut]=...
    function_Preprocess(J1);
    
%J1はグレースケールの画像
HeightScale=256;
WidthScale=256;
ImgOut(1:HeightScale,1:WidthScale)=0;

    
    SSJ=size(J1); 
    xxmax=0; xxmin=100000; xxmean=0; yymean=0; nn=0;
    for xx=1:SSJ(1,1)
        for yy=1:SSJ(1,2)
            if J1(xx,yy)~=0
                if xx>xxmax
                    xxmax=xx;
                end
                if xx<xxmin
                    xxmin=xx;
                end
                xxmean=xxmean+xx;
                yymean=yymean+yy;
                nn=nn+1;
            end
        end
    end
    xxmean=xxmean/nn;
    yymean=yymean/nn;
    
    Scale=sqrt((pi*50^2)/sum(sum(J1)));
    I1=imresize(J1,Scale,'bilinear');
    SSI=size(I1);
    
    for xx=floor(xxmean*Scale)-HeightScale/2+1:floor(xxmean*Scale)+HeightScale/2
        for yy=floor(yymean*Scale)-WidthScale/2+1:floor(yymean*Scale)+WidthScale/2
            if xx>0&&xx<SSI(1,1)&&yy>0&&yy<SSI(1,2)
                ImgOut(xx-(floor(xxmean*Scale)-HeightScale/2),yy-(floor(yymean*Scale)-WidthScale/2))=ImgOut(xx-(floor(xxmean*Scale)-HeightScale/2),yy-(floor(yymean*Scale)-WidthScale/2))+I1(xx,yy);
            end
            if yy<0||yy>SSI(1,2)
                ImgOut(xx-(floor(xxmean*Scale)-HeightScale/2),yy-(floor(yymean*Scale)-WidthScale/2))=ImgOut(xx-(floor(xxmean*Scale)-HeightScale/2),yy-(floor(yymean*Scale)-WidthScale/2))+0;
            end
        end
    end
      
    
end