want to calculate std_value and mean_value
5 次查看(过去 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!