Cody

# Problem 682. Image Processing 002 : Fix Vignetting in a Visible Sensor

Solution 3367233

Submitted on 25 Oct 2020 by Rafael S.T. Vieira
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%Typical Vignette load penny.mat; Timg=double(P); Timg=Timg+250; [nr nc]=size(Timg); obscuration=zeros(1,nc); widthL=24; widthR=16; maxobsL=.16; maxobsR=.20; % ObscurationLinear obscuration(1:1+widthL)=maxobsL*(widthL-(0:widthL))/widthL; obscuration(end:-1:end-widthR)=maxobsR*(widthR-(0:widthR))/widthR; Vimg=bsxfun(@times,Timg,1-obscuration); % Processing Fimg=Vignette_fix(Vimg,obscuration); % % Verification tolerance=[0.01 1]; Pass=1; % Hi check tcheck=(Timg*(1+tolerance(1))+tolerance(2))-Fimg; if min(tcheck(:))<0,Pass=0;end % Lo check tcheck=Fimg-(Timg*(1-tolerance(1))-tolerance(2)); if min(tcheck(:))<0,Pass=0;end assert(isequal(Pass,1))

2   Pass
% Low Image Signal load penny.mat; Timg=double(P); Timg=Timg+50; [nr nc]=size(Timg); obscuration=zeros(1,nc); widthL=16; widthR=12; maxobsL=.08; maxobsR=.12; % ObscurationLinear obscuration(1:1+widthL)=maxobsL*(widthL-(0:widthL))/widthL; obscuration(end:-1:end-widthR)=maxobsR*(widthR-(0:widthR))/widthR; Vimg=bsxfun(@times,Timg,1-obscuration); % Processing Fimg=Vignette_fix(Vimg,obscuration); % % Verification tolerance=[0.01 1]; Pass=1; % Hi check tcheck=(Timg*(1+tolerance(1))+tolerance(2))-Fimg; if min(tcheck(:))<0,Pass=0;end % Lo check tcheck=Fimg-(Timg*(1-tolerance(1))-tolerance(2)); if min(tcheck(:))<0,Pass=0;end assert(isequal(Pass,1))

3   Pass
%Timg = double(imread('concordorthophoto.png')); % Matlab full image Timg =double(imread('example.tif')); % NGC 6543 Timg=Timg(1:512,1:512); Timg=Timg+400; % Nominal 20 [nr nc]=size(Timg); obscuration=zeros(1,nc); widthL=48; widthR=40; maxobsL=.2; % chan 1 Vig = 0.1842 maxobsR=.15; % Chan 512 Vig = 0.1359 % Obscuration 4th order obscuration(1:1+widthL)=maxobsL*(((1:1+widthL)-(1+widthL)).^4/(widthL+1)^4); obscuration(end-widthR:end)=maxobsR*(((widthR+1:-1:1)-(1+widthR)).^4/(widthR+1)^4); Vimg=bsxfun(@times,Timg,1-obscuration); % Processing Fimg=Vignette_fix(Vimg,obscuration); % % Verification tolerance=[0.01 1]; Pass=1; % Hi check tcheck=(Timg*(1+tolerance(1))+tolerance(2))-Fimg; if min(tcheck(:))<0,Pass=0;end % Lo check tcheck=Fimg-(Timg*(1-tolerance(1))-tolerance(2)); if min(tcheck(:))<0,Pass=0;end assert(isequal(Pass,1))

4   Pass
% Timg = double(imread('concordorthophoto.png')); % Matlab full image %Timg=Timg(1600:2111,900:1411); Timg =double(imread('example.tif')); % NGC 6543 Timg=Timg(31:542,81:592); Timg=Timg+300; [nr nc]=size(Timg); obscuration=zeros(1,nc); widthL=42; widthR=36; maxobsL=.18; % maxobsR=.23; % % Obscuration Linear obscuration(1:1+widthL)=maxobsL*(widthL-(0:widthL))/widthL; obscuration(end:-1:end-widthR)=maxobsR*(widthR-(0:widthR))/widthR; Vimg=bsxfun(@times,Timg,1-obscuration); % Processing Fimg=Vignette_fix(Vimg,obscuration); % % Verification tolerance=[0.01 1]; Pass=1; % Hi check tcheck=(Timg*(1+tolerance(1))+tolerance(2))-Fimg; if min(tcheck(:))<0,Pass=0;end % Lo check tcheck=Fimg-(Timg*(1-tolerance(1))-tolerance(2)); if min(tcheck(:))<0,Pass=0;end assert(isequal(Pass,1))

### Community Treasure Hunt

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

Start Hunting!