How much is an image brightened using imlocalbrighten?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Deanna Edwing
am 25 Mai 2023
Bearbeitet: Sulaymon Eshkabilov
am 26 Mai 2023
I am using inlocalbrighten to brighten up some Sentinel-1 imagery for use in flood detection. I know the default amount is 1 if no 'amount' is specified, but what does this actually mean?
The source code is relativly vague, saying that using the default value of 1 'brightens the image by as much as possible' but I would like to understand how an input image is transformed using this function.
I am relatively new to using matlab for image processing so anything helps, thanks!
0 Kommentare
Akzeptierte Antwort
Sulaymon Eshkabilov
am 25 Mai 2023
You are talking about imlocalbrighten(), correct?!
It is really straight forward to understand how to works and to what extend it changes pixel values of the lowest bright points of a given image. It can be done by comparing lowest brightened pixel values (red, green, blue) by applying imlocalbrighten(), e.g.:
A = imread("Original.jpg");
% Lowest bright (darkest spots) pixels are lower left corner, e.g.: [600,200,:]
O=A(600,200,:); O = O(:)
subplot(241)
image(A)
title('Original')
% Now, let's apply the image brightening fcn with 1:
% Case 1. Brighening value 1
B1 = imlocalbrighten(A, 1);
subplot(242)
image(B1)
title('Brighten=1')
B1=B1(600,200,:); B1 = B1(:)
% Case 2. Brighening value: 0.75
B2 = imlocalbrighten(A, 0.75);
subplot(243)
image(B2)
title('Brighten=0.75')
B2=B2(600,200,:); B2 = B2(:)
% Case 3. Brighening value: 0.5
B3 = imlocalbrighten(A, 0.50);
subplot(244)
image(B3)
title('Brighten=0.50')
B3=B3(600,200,:); B3 = B3(:)
% Augment all values and compare them again using heatmap()
ALL = [O', B1' B2', B3'];
xvalues = {'O_{red}', 'O_{green}', 'O_{blue}', ...
'B1_{red}', 'B1_{green}', 'B1_{blue}',...
'B2_{red}', 'B2_{green}', 'B2_{blue}',...
'B3_{red}', 'B3_{green}', 'B3_{blue}',};
figure
heatmap(xvalues,1, ALL), colormap('jet')
4 Kommentare
DGM
am 26 Mai 2023
Image data is expected to lie within a certain range which depends on the numeric class of the data. For integer classes, that's the available dynamic range of the class. For floating point classes, it's [0 1].
While you can have image data on any scale you want, you need to be aware of what is expected by other tools. Anything that needs to rescale your image needs to know where black and white are. The only way anything knows (usually) is this relationship between class and implied scale. Consider the three "images":
A = [0 0.25 0.5 1] % unit-scale float, as obtained from some function
B = im2uint8(A) % uint8, as would be written to a PNG file on disk
C = round(A*255) % improperly-scaled float
As far as most tools are concerened, A and B are essentially the same image represented in different classes. They'll display the same. C is just a white image with one black pixel.
So you have a floating point image. Imlocalbrighten() sees that and expects everything to be within [0 1]. Anything outside that interval is truncated in the call to imreducehaze(). The image that it operates on strictly lies within [0 1]. The class of the output is inherited from the input, and the scale of the output is determined by the class of the input, not the scale or range of the input.
Since your input to imlocalbrighten() is floating-point, the output scale is [0 1]. When you save your image with imwrite(), it has to be converted to uint8, since that's what's actually stored in the file. So the image read from disk will have a nominal range of [0 255].
FWIW, I don't know that I'd really call your image "improperly-scaled", though. It's probably scaled fine, but its range exceeds what's expected. It's likely that it simply contains some spurious outlier values that should be truncated, but that's not my decision to make since I don't know what caused them.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!