How much is an image brightened using imlocalbrighten?

13 ビュー (過去 30 日間)
Deanna Edwing
Deanna Edwing 2023 年 5 月 25 日
編集済み: Sulaymon Eshkabilov 2023 年 5 月 26 日
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!

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 5 月 25 日
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(:)
O = 3×1
8 7 5
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(:)
B1 = 3×1
62 48 0
% 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(:)
B2 = 3×1
55 42 1
% 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(:)
B3 = 3×1
39 30 2
% 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 件のコメント
Deanna Edwing
Deanna Edwing 2023 年 5 月 25 日
Hi again, one last question. I went back and looked at the range of my input data (0.0018 - 512.3). Most of the data is between 0-1 though. However, when I run imlocalbrighten, the output only ranges from 0-1. Why is that? Is this just how this function interacts with .tif grayscale imagery?
Because when I convert it to a PNG later on, the imagery looks fine because it gets scaled between 0-255, but I don't understand how the output of the imlocalbrighten function can have a smaller range than the input.
DGM
DGM 2023 年 5 月 26 日
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
A = 1×4
0 0.2500 0.5000 1.0000
B = im2uint8(A) % uint8, as would be written to a PNG file on disk
B = 1×4
0 64 128 255
C = round(A*255) % improperly-scaled float
C = 1×4
0 64 128 255
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.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by