%read image
grayimage = imread('unknown.jpg');
% grab the number of rows, columns, and channels
[nr, nc, nChannels]=size(grayimage);%nr=height, nc=width, nChannels=3, RGB
%highest gray values
maxgray = max(grayimage(:));
[grayidxrow, grayidxcol] = find(grayimage == maxgray);
%assume that the original value at that location was 255
originalvalue = 242;
[originalidxrow, originalidxcol] = find(grayimage == originalvalue);
imgCntX = (nc+1)/2;
imgCntY = (nr+1)/2;
%distance from center pixel to corner pixel (1,1)
maxDistance = sqrt((imgCntY-1)^2 + (imgCntX-1)^2);
%distance from center to the current pixel.
%dis = sqrt (abs(grayidxrow-imgCntY).^2 + abs(grayidxcol-imgCntX).^2);
dis = sqrt (abs(1133-imgCntY).^2 + abs(1247-imgCntX).^2);
%we know that vignettImg(i,j) = inputImage(i,j)* (1 - scaleLevel *(dis/maxDistance) );
scaleLevel = (1-232/originalvalue)*maxDistance/dis;