필터 지우기
필터 지우기

The image calculation found that they are all black or all white.

조회 수: 3 (최근 30일)
bozheng
bozheng 2023년 10월 26일
답변: Image Analyst 2024년 4월 28일
The image calculation found that they are all black or all white.
my coding
img1= imread('SCM Data111.jpg');
img = (-0.18 / (-0.28 / (45.39 /img1 - 1))+1) * 5.3;
imwrite(img, 'n_.jpg');
Can you tell me the reason why the subsequent pictures are all black and how to solve it?

채택된 답변

Walter Roberson
Walter Roberson 2023년 10월 26일
img = (-0.18 / (-0.28 / (45.39 /double(img1) - 1))+1) * 5.3;
When you do calculations with integer datatypes, the results of the calculations are converted to the integer data type.
  댓글 수: 3
Walter Roberson
Walter Roberson 2023년 10월 26일
Your formula divides by the input, but parts of the input can be 0 (especially where there is black.) That leads to large output values in places -- but also leads to small output values for a lot of the image because the division by the large-valued components comes out small.
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1521731/image.jpeg';
img1 = imread(filename);
min(img1(:)), max(img1(:))
ans = uint8 0
ans = uint8 255
img = (-0.18 / (-0.28 / (45.39 /double(img1) - 1))+1) * 5.3;
min(img(:)), max(img(:))
ans = 2.4993
ans = Inf
syms x
Q = @(v) sym(v);
imgs = (-Q(0.18) / (-Q(0.28) / (Q(45.39) /x - 1))+1) * Q(5.3)
imgs = 
fplot(imgs, [0 255])
ir = uint8(rescale(img, 0, 255, 'InputMin', 2.5, 'InputMax', 50));
imshow(ir); colorbar
bozheng
bozheng 2024년 4월 28일
can you tell me why we know the value is 'InputMin', 2.5, 'InputMax', 50 thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2024년 4월 28일
img1 is an array so you need to use dot division
img = (-0.18 ./ (-0.28 ./ (45.39 ./ img1 - 1)) + 1) * 5.3;
And double check your parentheses to make sure they're correct. For example is
(45.39 ./ img1 - 1)
supposed to be
((45.39 ./ img1) - 1)
or
(45.39 ./ (img1 - 1))

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by