want to calculate std_value and mean_value
조회 수: 4 (최근 30일)
이전 댓글 표시
below is my coding but i dont what happend i dont get data
------------------------
img1 = imread('SCM Data.jpg');
img = (-0.18 / (-0.28 / (45.39 / double(img1) - 1)) + 1) * 5.3;
std_value = std2(img);
mean_value = mean2(img);
fprintf('standard deviation:%.2f\n', std_value);
fprintf('average value:%.2f\n', mean_value);
-----------------------
by the way if i conducted calculate it will chage to
댓글 수: 0
채택된 답변
Star Strider
2023년 10월 27일
There are 395449 ‘Inf’ values in ‘img’ (probably the result of the subtraction in the denominator of the transformation) so those are going to produce either Inf or NaN values in the mean and standard deviation. One way to deal with that is to assign all the Inf values to be NaN and then use the new fillmissing2 function (R2020a does not have it, and I am not certain what to suggest in its absence other than perhaps fillmissing and then hope for the best, since it seems to produce the same result) on each channel of ‘img’.
Then, do the statistics —
img1 = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1523076/image.jpeg');
img = (-0.18 / (-0.28 / (45.39 / double(img1) - 1)) + 1) * 5.3;
size(img)
nans = nnz(isnan(img)) % Check 'NaN' Values
infs = nnz(isinf(img)) % Check 'Inf' Values
img(isinf(img)) = NaN; % Assign 'Inf' Values To 'NaN'
imgz = zeros(size(img));
for k = 1:size(img,3)
img(:,:,k) = fillmissing2(img(:,:,k), 'nearest');
imgz(:,:,k) = fillmissing(img(:,:,k), 'nearest');
end
std_value = std2(img);
mean_value = mean2(img);
fprintf('standard deviation:%.2f\n', std_value);
fprintf('average value:%.2f\n', mean_value);
std_value = std2(imgz);
mean_value = mean2(imgz);
fprintf('standard deviation:%.2f\n', std_value);
fprintf('average value:%.2f\n', mean_value);
This uses the provided image, that includes the borders and colorbar. (I did not crop it.) You will likely get different results from your actual image (that ideally should have been provided).
.
댓글 수: 2
Star Strider
2023년 10월 27일
Just use fillmissing. When I checked (included in my code), it gave the same result as fillmissing2.
img1 = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1523076/image.jpeg');
img = (-0.18 / (-0.28 / (45.39 / double(img1) - 1)) + 1) * 5.3;
size(img)
nans = nnz(isnan(img)) % Check 'NaN' Values
infs = nnz(isinf(img)) % Check 'Inf' Values
img(isinf(img)) = NaN; % Assign 'Inf' Values To 'NaN'
for k = 1:size(img,3)
img(:,:,k) = fillmissing(img(:,:,k), 'nearest');
end
std_value = std2(img);
mean_value = mean2(img);
fprintf('standard deviation:%.2f\n', std_value);
fprintf('average value:%.2f\n', mean_value);
.
추가 답변 (1개)
Sulaymon Eshkabilov
2023년 10월 27일
Here is the correct code:
img1 = imread('ALPS.jpg');
figure
imshow(img1); title('Original Image')
std_value1 = std2(img1);
mean_value1 = mean2(img1);
fprintf('Original Image: \n')
fprintf('standard deviation:%.5f\n', std_value1);
fprintf('average value:%.5f\n', mean_value1);
img2 = (-0.18./(-0.28/(45.39./(img1)- 1))+1) * 5.3;
std_value2 = std2(img2);
mean_value2 = mean2(img2);
fprintf('Changed Image: \n')
fprintf('standard deviation:%.5f\n', std_value2);
fprintf('average value:%.5f\n', mean_value2);
figure
% See why std2 is giving '0'
imshow(img2), title('Changed Image')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!