I have two binary images one as ground truth image and other as experimental/testing image. I want to calculate true positive, false positive and false negative where my region of interest is blobs (i.e. circle and ellipse) present in the images.
For the true positive, the intersection of images using 'or bitwise' operation was performed along with counting a total of black pixels present in the intersected image as 'Total number of True Positive pixels',i.e, TP.
For false positive, pixels having value 255 in the ground-truth image was considered and a total of white pixels assigned as'Total number of False Positive',i.e, FP
For false negative pixels having value 255 in experimental-image was considered and a total of white pixels assigned as 'Total number of False Negative',i.e., FN
Precision and Recall is calculated as:
Precision as TP / (TP + FP)
Recall as TP / (TP + FN)
It seems the values are calculated wrong as I got precision to be 19%.
Please guide me on this.
Thanks in advance.
Related
When we want to assess the quality of a positive prediction made by the model, which is the number of true positives divided by the total number of positive predictions.
Also, the recall shows the model's ability to detect positive samples and biases towrds negative predictions, which is the ratio between the numbers of true positivto the total number of positive samples.
Is there any meaning in the ratio between True negative and all negative predictions??
The false positive rate is the x-axis spanning from 0 to 1. The true positive rate is the y-axis spanning from 0 to 1. And the graphs show data points like (.8,.8). Which if the tpr is .8 and the fpr is .8, they add up to 1.6...
Typically the axis are normalised using the total number of FPs or TPs in the test/validation set. Otherwise the end of the curve wouldn't be 1/1. I personally prefer to label the axis by the number of instances.
Why to not normalise by the total number - in real applications, it gets rather complicated as you often do not have labels for all examples. The typical example for ROC curves are mass mailings. To normalise the curve correctly you would need to spam the entire world.
I know that the ROC-Curve is calculated from the True-Positive-Rate and the False-Positive-Rate.
But the ROC-Curve has infinite Elements on it's Curve, right? How is each Element calculated? Can someone explain this to me? Where is each point coming from?
Example
Thanks in Advance
The values are calculated for all values of the threshold of the classifier.
On the x axis, you have the "false positive rate" for the given threshold: FPR = FP / (TN + FP) where:
FP are the number of false positive (the elements predicted positive but which are negative);
TN the number of true negative (the elements predicted negative and are really negative);
and FP the number of false positive (the elements predicted positive but are negative).
On the y axis, you have the "true positive rate" for the given threshold: TPR = TP / (TP + FN) where:
TP are the number of true positive (predicted positive and are indeed positive);
FN the number of false negative (predicted negative but are positive).
You have not an infinite number of points in practice: you are limited to the number of points of the dataset (the rate dont change for some ranges of threshold).
I have a 8-bit image and I want to filter it with a matrix for edge detection. My kernel matrix is
0 1 0
1 -4 1
0 1 0
For some indices it gives me a negative value. What am I supposed to with them?
Your kernel is a Laplace filter. Applying it to an image yields a finite difference approximation to the Laplacian operator. The Laplace operator is not an edge detector by itself.
But you can use it as a building block for an edge detector: you need to detect the zero crossings to find edges (this is the Marr-Hildreth edge detector). To find zero crossings, you need to have negative values.
You can also use the Laplace filtered image to sharpen your image. If you subtract it from the original image, the result will be an image with sharper edges and a much crisper feel. For this, negative values are important too.
For both these applications, clamping the result of the operation, as suggested in the other answer, is wrong. That clamping sets all negative values to 0. This means there are no more zero crossings to find, so you can't find edges, and for the sharpening it means that one side of each edge will not be sharpened.
So, the best thing to do with the result of the Laplace filter is preserve the values as they are. Use a signed 16-bit integer type to store your results (I actually prefer using floating-point types, it simplifies a lot of things).
On the other hand, if you want to display the result of the Laplace filter to a screen, you will have to do something sensical with the pixel values. Common in this case is to add 128 to each pixel. This shifts the zero to a mid-grey value, shows negative values as darker, and positive values as lighter. After adding 128, values above 255 and below 0 can be clipped. You can also further stretch the values if you want to avoid clipping, for example laplace / 2 + 128.
Out of range values are extremely common in JPEG. One handles them by clamping.
If X < 0 then X := 0 ;
If X > 255 then X := 255 ;
I used Make3D dataset to estimate depth maps. I want to calculate precision and recall for each test image. But i have no idea how to do it with images specially how to find True/false positive and false negative from my results and the data.
I know only that :
Precision = tp/(tp+fp)
Recall = tp/(tp+fn)
With tp=True Positives, fp=False Positives and fn=False Negatives.
So how to calculate tp,fp and fn when i have pixels ?