Need help on function "isfinite" funtion

1 次查看(过去 30 天)
Can someone help me with isfinite funtion in maltab? I m wondering how this funtion can be used to determined sqrt mean error, median, mean,prctile, of error in each pixel of image 3D reconstruction.
  2 个评论
Rik
Rik 2023-6-23
It can't do that. It will do exactly what the documentation tells you: return a logical array indicating whether a value is NaN/inf or not.
Generally this is a first step in selecting valid datapoints to do further calculations. Those further calculations may include computing the RMSE, median, mean, and/or perctiles.
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If you have questions after that, have a read here and here. It will greatly improve your chances of getting an answer.
dpb
dpb 2023-6-23
The typical use in those would be to use it as @Rik points out -- as a logical addressing vector/array.
If your dataset does include values that are NaN/Inf, then
mnA=mean(A(isfinite(A)));
will return the mean excluding those elements in the array that are not finite.
There is an 'omitnan' flag built into many of the functions that return population statistics like mean, but not in other standard functions such as sqrt(). The use of that flag, however, traps only NaN values, an Inf will still result in Inf as the result; only isfinite() handles both.

请先登录,再进行评论。

回答(1 个)

Dheeraj
Dheeraj 2023-8-9
Hi,
isfinite” function cannot be directly used to find square mean error, median, mean, percentile of error in each pixel of a 3D image reconstruction, but can be used to identify error cells and apply desired statistic functions on the finite error valued cells.
Assuming you have your reconstructed image and the ground truth image, the code below demonstrates how “isfinite” can be used as the initial step to calculate the necessary statistical measures.
% Step 1: Compute the error for each pixel
error = groundTruthImage - reconstructedImage;
% Step 2: Identify finite elements in the error array
finiteError = error(isfinite(error));
% Step 3: Calculate the desired statistics
sqrtMeanError = sqrt(mean(finiteError));
medianError = median(finiteError);
meanError = mean(finiteError);
prctileError = prctile(finiteError, 75); % Replace 75 with the desired percentile
you could refer to the following documentation for better understanding.

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by