Georeferenced Edge Detection Analysis
3 views (last 30 days)
Show older comments
I am trying to analysis the results of edge detection algorithms compared to reference data. However I am encountering a few problems. Firstly as the two matrices were of differing size I used padarray to increase the size of the smaller array to the larger one. However the problem with this was that the reference data did not always lie in the true position of the correct edges so affected my results. I am using the True Positive, False Negative, False Positive and True Negative to calculate the Total Positive Rate, Branching Factor and Quality Percentage, stated in McKeown et al. (2000), using the following code;
function [TPR,BF,QP]= Quantify(Candidate,Reference)
TP=sum(((Reference==1) + (Candidate==1))==2);
FN=sum(((Reference==1) + (Candidate==0))==2);
FP=sum(((Reference==0) + (Candidate==1))==2);
TN=sum(((Reference==0) + (Candidate==0))==2);
TPR = 100*TP/(TP+FN)
BF = FP/TP
QP = 100*TP/(TP+FP+FN)
end
The data I am using has world files associated to the data. I am therefore wondering if there is a way that I can use the world file data to compare the data against each other whilst in its correct geographic location? The datasets being compared are both logical datasets in OSGB36. Also how can I overcome the previous problems with different matrix sizes if they are first coordinate is located at different positions.
I hope this makes sense and look forward to your responses. If any more information is required please comment and I'll try to explain it further.
Andrew
0 Comments
Answers (1)
Hari
on 11 Jun 2025
Hi,
I understand that you’re comparing edge detection results against a reference dataset using metrics like True Positive Rate, Branching Factor, and Quality Percentage. However, the challenge is that the candidate and reference edge matrices differ in size and position due to their geographic alignment, even though both are in the OSGB36 coordinate system.
I assume that both datasets come with associated world files (like .tfw) that define their spatial referencing, and that you’re looking to use this information to properly align the datasets for pixel-by-pixel comparison.
In order to do this comparison in the correct geographic context, you can follow the below steps:
Step 1: Use the world files to read georeferencing information
Load the spatial referencing from each image’s world file using functions that can return referencing objects (like worldFileMatrix or georasterref). This provides the geographic coordinates for each pixel.
Step 2: Align the datasets in a common spatial grid
Use the referencing objects to reproject or resample one dataset to match the other's spatial grid. The function imwarp or mapresize along with imref2d can help resample the candidate to the same spatial extent and resolution as the reference.
Step 3: Crop or pad after spatial alignment
Once both matrices are spatially aligned using their world coordinates, then crop or pad as necessary to ensure they are the same matrix size. This step avoids shifting edges incorrectly because the alignment is already geographic.
Step 4: Perform binary comparison using your existing metrics
Now that both binary edge matrices are in the same spatial frame, your metric calculations (TP, FP, FN, TN) will be more accurate and meaningful.
Step 5: Validate results visually and statistically
As a sanity check, overlay the aligned edge results onto a basemap or reference image using imshowpair or similar tools, to verify correct alignment before computing metrics.
References:
Hope this helps!
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!