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

3 ビュー (過去 30 日間)
ghada sandoub
ghada sandoub 2019 年 3 月 11 日
コメント済み: ghada sandoub 2019 年 3 月 13 日
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 件のコメント
Rik
Rik 2019 年 3 月 12 日
So you want a window average, but with a maximum, with a 15-by-15-by-size(I,3) window?
ghada sandoub
ghada sandoub 2019 年 3 月 12 日
I think that..

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

採用された回答

Image Analyst
Image Analyst 2019 年 3 月 12 日
編集済み: Image Analyst 2019 年 3 月 12 日
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 件のコメント
Image Analyst
Image Analyst 2019 年 3 月 13 日
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 2019 年 3 月 13 日
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.

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

その他の回答 (1 件)

Rik
Rik 2019 年 3 月 12 日
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

Community Treasure Hunt

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

Start Hunting!

Translated by