image processing for the vignetting

3 ビュー (過去 30 日間)
matlabgeek
matlabgeek 2016 年 1 月 21 日
コメント済み: Rena Berman 2017 年 1 月 24 日
Hello Sir,
If you could help me, it will help me a lot. I attached my code in the comment which I wrote, please correct me.
I want to do something about vignetting on image.
I want to calculator f scale factor for the vignetting.
I have the following algorithm, I need to implement it using Matlab.
  1. Take an unknown image (which is in the attachment, it is a image after vignetting)
  2. Then, find the highest gray values the image, Say the maximum value is Max1 in the image. Say there are 100 such values Max1 through the image.
  3. For each of those values, assume that the original value at that location was 255. Using the following formula, find the f value for those 100 locations. This means you solve for f, since you know a, b, D and r for each of the 100 different locations.
  4. Then we average this 100 values to get get the f
Formula:
outputPixel = inputPixel ? (1 ? f ? (d/maxDistance))
maxDistance = OC, C is the center of the rectangle (image).
d is the distance from center to the current pixel.
f is the scale factor, 0 ? f ? 1, if f=0, outputPixel = inputPixel.
  2 件のコメント
matlabgeek
matlabgeek 2016 年 1 月 21 日
編集済み: Walter Roberson 2016 年 1 月 21 日
%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;
Rena Berman
Rena Berman 2017 年 1 月 24 日
(Answers dev) Restored question.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2016 年 1 月 21 日
See my attached background correction demo. This will "flatten" an image according to a vignetted or shaded "uniform" background.
  2 件のコメント
matlabgeek
matlabgeek 2016 年 1 月 21 日
編集済み: matlabgeek 2016 年 1 月 21 日
Thank you for your answer.It looks like you program is changed the vignetted image back to original image?
Image Analyst
Image Analyst 2016 年 1 月 21 日
If you still want this answered, then edit your original post and have it make sense again, and attach your picture and say what you want to do with it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by