Need help on function "isfinite" funtion

1 view (last 30 days)
pizzaa
pizzaa on 23 Jun 2023
Answered: Dheeraj on 9 Aug 2023
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 Comments
Rik
Rik on 23 Jun 2023
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 on 23 Jun 2023
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.

Sign in to comment.

Answers (1)

Dheeraj
Dheeraj on 9 Aug 2023
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.

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!