View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Slant Edge Script

3.6 | 12 ratings Rate this file 55 Downloads (last 30 days) File Size: 394 KB File ID: #28631 Version: 1.0
image thumbnail

Slant Edge Script



This code can be used to measure the pre-sampled MTF of an image.

| Watch this File

File Information

This code can be used to measure the pre-sampled MTF of an image, which is a quantity that describes the resolution of linear imaging systems. The code is based on measuring the pre-sample MTF using a precision machined edge that is aligned - with respect to the columns or rows of an image - at an angle between 1-5 degrees.
To learn more about the pre-sampled MTF consult the references at the end of this script.

When you run this script your image containing the edge with appear with the cropping tool. Crop your image to the region containing only the edge. Double-click your cropped area for the script to continue.

A Gaussian fitting tool has been used in this code. You can download this tool on the Matlab central website here:

comments, and suggestions, including areas of improvement may be welcomed.


Gaussian Curve Fit inspired this file.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (25)
17 Nov 2016 Tunhe

Tunhe (view profile)

For repeated value affecting interp1 one can use unique() or find(diff()==0) to remove/locate/manipulate them so that interpolation can go through.

Comment only
08 Apr 2016 Evan

Evan (view profile)

Very sensitive to the input edge images? Always saying the interp1 errors, is it because the interpolation contains too many duplicate values? How to fix it? Thx.

Comment only
29 Mar 2016 dongri meng

Do you guys have a sample edge image for me to try out? My own image keep getting errors.

Thanks a bunch!

Comment only
29 Mar 2016 dongri meng

29 Feb 2016 Parimalah Velo

Really helpful. Thank you for sharing.

17 Dec 2015 Louise Morel

Does this script work regardless of wether the image data has been linearized to the deposited-energy ?
I used this script on image data that I know is not linearized relative to the deposited energy and I still get seemingly correct MTF results. How is this possible ?

Comment only
11 Sep 2015 Harry Chen

I was trying to estimate the relative edge response of a natural image. This code makes my job much easier.


11 Sep 2015 Basim Kakakhel

Is anyone getting the following error

Index exceeds matrix dimensions.

Error in MTFscript (line 230)
array_values_near_edge(ii,:) = (image(i,bound_edge_left_expand:bound_edge_right_expand));

Comment only
06 Feb 2015 Hai Lai

15 Dec 2014 Eamon Loughman

What type of smoothing would marcelo or rachel reccomend?

Having done some tinkering with wiener and Gaussian filtering of the image files, I still seem to hit errors?

Very well written in all other respects!

04 Dec 2014 Patrick Granton

* Feel free to tinker everyone... perhaps I'll revisit this script and re-write to more common code practices.

Comment only
04 Dec 2014 Marcelo Soto Thompson

Agree with Rachel.This script is not very robust to noise.

I have also found it to crash if the edge is very blurry ie extends over many (50 or so) pixels.

Also, it's always unfortunate and poor practice to name variables the same as built-in functions (e.g "image").

Having said that, with a little tinkering this script is quite nice and will get the job done.

03 Dec 2014 Rachel

Rachel (view profile)

I've been creating my own MTF script, and I wanted to compare my results to yours. However, because my slanted edge must include noise for what I'm testing, I am unable to use your program. The issue happens at line 218, because to find the edge you use interp1, and the variable "strip_cropped" is not monotonic increasing due to the noise in my image. Perhaps you could use a different smoothing method, or use thresholding before finding the subpixel edge. Otherwise, everything else looks like it would work great!

25 Oct 2014 Karbala'a Unvi. Science

hi there i need the slant wave let for the image and what is the result needed urgently

Comment only
29 Jul 2014 Adam

Adam (view profile)

Hi Patrick,

I have .mat file which containes 200x200 pixels of 50 um size. But the MTFscript does not work!!

Comment only
01 Apr 2014 Kelly

Kelly (view profile)

Hi Patrick,

I am receiving an error at line 230 about that the index are not integers or logical.
Could you please tell me that what is the problem behind.

Comment only
13 Mar 2014 Nad

Nad (view profile)

Hi Patrick,

thanks a lot. The code worked for me without bug with the exemplary dicom image.

13 Mar 2014 Nad

Nad (view profile)

24 Jul 2013 Muhammad Ghani

Hi Patrick, I am receiving an error at line 232 about that the index are not integers or logical.
Could you please tell me that what is the problem behind. I am in desperate help need

06 Feb 2013 Shimon Zerbib

impossible to download the file ...

Comment only
15 Jan 2013 Cristina

I am very new to matlab so my question might be silly, but every time I double click on the cropped area, I get the following error:

Error using interp1 (line 257)
The values of X should be distinct.

Error in SlantEdgeScript (line 218)
edge_position_temp = interp1(strip_cropped,temp_y,threshold,'pchip');

I am stuck at this error and can't proceed. Any advice would be greatly appreciated.

Comment only
04 Dec 2012 Pierre

Pierre (view profile)

i didn't have any problem with the cropping.
I had to modify the way to estimate the variable level.
and I had to modify many things after because the program worked only when the image is not noisy at all.
(I had to modify the way to find the edge position).

Comment only
25 Nov 2012 Patrick Granton

Pierre, I fixed some issues with the cropping of the image and have made it a GUI for more easy of use. Perhaps this might help you.

Comment only
22 Nov 2012 Pierre

Pierre (view profile)

doesn't work at all.

lot of error to debug in it.

12 Apr 2012 XIN JIN

Excellent code! It helps a lot. Appreciate for this.

Contact us