Borrar filtros
Borrar filtros

want to calculate std_value and mean_value

4 visualizaciones (últimos 30 días)
bozheng
bozheng el 27 de Oct. de 2023
Comentada: Star Strider el 27 de Oct. de 2023
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

Respuesta aceptada

Star Strider
Star Strider el 27 de Oct. de 2023
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)
ans = 1×3
755 869 3
nans = nnz(isnan(img)) % Check 'NaN' Values
nans = 0
infs = nnz(isinf(img)) % Check 'Inf' Values
infs = 395449
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);
standard deviation:46.14
fprintf('average value:%.2f\n', mean_value);
average value:29.48
std_value = std2(imgz);
mean_value = mean2(imgz);
fprintf('standard deviation:%.2f\n', std_value);
standard deviation:46.14
fprintf('average value:%.2f\n', mean_value);
average value:29.48
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 comentarios
bozheng
bozheng el 27 de Oct. de 2023
nans =
0
infs =
395449
Unrecognized function or variable 'fillmissing2'.
Error in
img(:,:,k) = fillmissing2(img(:,:,k), 'nearest');
Star Strider
Star Strider el 27 de Oct. de 2023
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)
ans = 1×3
755 869 3
nans = nnz(isnan(img)) % Check 'NaN' Values
nans = 0
infs = nnz(isinf(img)) % Check 'Inf' Values
infs = 395449
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);
standard deviation:47.28
fprintf('average value:%.2f\n', mean_value);
average value:30.55
.

Iniciar sesión para comentar.

Más respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 27 de Oct. de 2023
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')
Original Image:
fprintf('standard deviation:%.5f\n', std_value1);
standard deviation:63.19555
fprintf('average value:%.5f\n', mean_value1);
average value:101.80412
img2 = (-0.18./(-0.28/(45.39./(img1)- 1))+1) * 5.3;
std_value2 = std2(img2);
mean_value2 = mean2(img2);
fprintf('Changed Image: \n')
Changed Image:
fprintf('standard deviation:%.5f\n', std_value2);
standard deviation:0.00000
fprintf('average value:%.5f\n', mean_value2);
average value:5.00000
figure
% See why std2 is giving '0'
imshow(img2), title('Changed Image')

Categorías

Más información sobre Feature Detection and Extraction en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by