how to estimate bright channel for color image in Matlab??

2 views (last 30 days)
how to estimate the bright channel prior for color image (convert the image of the spatial domain into Brightness Domain) using the following formula:
Capture.JPG
Does anyone know how to do this in Matlab??
  4 Comments
Rik
Rik on 12 Mar 2019
So you want a window average, but with a maximum, with a 15-by-15-by-size(I,3) window?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 12 Mar 2019
Edited: Image Analyst on 12 Mar 2019
The inner operation is dilation. The outer one is max. So simply dilate each color channel (take the max in a 15x15 window) with imdilate(). Like for the red channel.
dilatedRed = imdilate(redChannel, ones(3));
Same for blue and green, then recombine into an rgb image and use max
brightnessImage = max(rgbImage, [], 3);
A full demo is attached.
0000 Screenshot.png
But I don't recall seeing this formula you gave. Taking the max is what you do to get L in the RGB-to-HSL, or to get the V in RGB-to-HSV formula. But they don't do dilation first. Not sure what that gets you, do you know? Why not just do it without dilation and use the built-in rgb2hsv() function
hsvImage = rgb2hsv(rgbImage); % Convert to HSV color space.
brightnessImage = hsvImage(:, :, 3); % Extract the V channel.
  5 Comments
Image Analyst
Image Analyst on 13 Mar 2019
Yes, except the order is switched. It is:
Imin = imerode(min(Ig, [], 3), ones(windowSize));
Where are you getting these formulas from? I can understand that the dark current signal might be estimated as the min of the red, green, and blue pixels in the demosaicing window but I really doubt any camera uses a demosaicing algorithm where the interpolated pixels are the uniformly weighted average inside a 15x15 window.
ghada sandoub
ghada sandoub on 13 Mar 2019
I'm working now in researching and I get these formulas from a paper that interested in low light image enhancement. this paper uses the bright channel formula to estimate the insufficient illumination in the low light image.

Sign in to comment.

More Answers (1)

Rik
Rik on 12 Mar 2019
Below you find 2.5 strategies. The first should be a lot faster, especially for larger images. With the last it is easier to see that the method returns the expected outcome.
clc
A=randi(20000,300,300,3);%random image
window=15;
%strategy 1:
tic
GetSingleLayerMax=@(A,window) nlfilter(A,[window window],@(x) max(x(:)));
maxIM=GetSingleLayerMax(A(:,:,1),window);
for n=2:size(A,3)
tmp=cat(3,maxIM,GetSingleLayerMax(A(:,:,n),window));
maxIM = max(tmp,[],3);
end
toc
%strategy 1b:
tic
GetSingleLayerMax2=@(A,window) colfilt(A,[window window],'sliding',@max);
maxIM_1b=GetSingleLayerMax2(A(:,:,1),window);
for n=2:size(A,3)
tmp=cat(3,maxIM_1b,GetSingleLayerMax2(A(:,:,n),window));
maxIM_1b = max(tmp,[],3);
end
toc
%strategy 2:
tic
maxIM2=zeros(size(A,1),size(A,2));
tmp=(1:window);tmp=tmp-mean(tmp);
tmp=ceil(tmp);%in case of even window size
[w_x,w_y,w_z]=meshgrid(tmp,tmp,1:size(A,3));
w=[w_x(:) w_y(:) w_z(:)];
for r=1:size(A,1)
for c=1:size(A,2)
%get all indices
tmp=w;
tmp(:,1)=w(:,1)+r;
tmp(:,2)=w(:,2)+c;
%remove invalid indices
tmp(any(tmp<1,2),:)=[];
tmp(tmp(:,1)>size(A,1),:)=[];
tmp(tmp(:,2)>size(A,2),:)=[];
%convert to linear indices
ind=sub2ind(size(A),tmp(:,1),tmp(:,2),tmp(:,3));
%compute the max
maxIM2(r,c)=max(A(ind));
end
end
toc
if isequal(maxIM,maxIM2) && isequal(maxIM_1b,maxIM2)
disp('everything finished succesfully')
else
disp('something went wrong (check for float rounding errors)')
end

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!