MTF_MAPPER(1)
πΈ NAME πΈ
ok so bestie, gather round, because this one is mtf_mapper(1) β it computes the MTF50 edge sharpness measure in images. that's the whole vibe. sharp edges, measured, slayed. π
β¨ SYNOPSIS β¨
mtf_mapper [OPTIONS] INPUT_IMAGE OUTPUT_DIR
π¦ DESCRIPTION π¦
so what does mtf_mapper actually do? it computes the edge acuity (that's sharpness, bestie) of slanted edges in images. and like, it doesn't need you to hold its hand β it automatically detects dark rectangular objects on light backgrounds, then computes the MTF50 values across each of the edges. main character energy, honestly.
the output comes in several forms β go peek at the -p, -s, -a and -q output options for all of that. π
and if you wanna test mtf_mapper? you can generate images with rectangles containing known MTF50 values using mtf_generate_rectangle. perfect little control group, no cap.
π OPTIONS π
here's the whole menu, no skips, every single one, because we don't do "tl;dr" around here. π«Ά
-tthreshold,--thresholdthreshold β sets the dark object threshold, and the default is0.55. you'll want lower values if your dark objects are actually light compared to the background β think gray rectangles instead of black rectangles, iykyk. and if MTF Mapper is acting like it can't see any dark objects at all, try lower values like0.3or even0.2. π--threshold-windowfraction β tells it what fraction of the smaller image dimension (height or width) gets used as the window size during the automatic thresholding that detects dark objects (that's the-tthing). default is0.3333, which is chef's kiss when your test chart has a white background. BUT if your dark targets have some other chart feature hanging around them (looking at you, QA-62 Scanner targets π), try shrinking this fraction. picking a fraction roughly equal to the size of the dark target (as a fraction of image height) should do the trick.-l,--linearβ linear input mode, periodt. it assumes an 8-bit input image has a linear intensity scale. the default behaviour is to assume that 8-bit input images have an sRGB gamma intensity profile (approximately gamma 2.2).--pixelsizesize β drop your sensor's pixel size (pitch) here, in microns. heads up: this option implicitly switches the MTF50 output units (for some output types) to line pairs per mm, akalp/mm. the default is cycles per pixel, akac/p.--bayerred|green|blue|noneβ process only the specified Bayer sites. this one is for bypassing the effects of Bayer demosaicing interpolation when you've got suitable raw images (likedcraw -doutput, love that for us). β οΈ if you specify this option on a demosaiced image you will not get the expected result β you must provide a raw image for this option to work correctly, fr fr. also keep in mind that Bayer red and blue each only cover 25% of the sensor, so your edges have to be 4 times longer to keep the same signal-to-noise ratio. minimum recommended edge lengths:35pixels for gray or interpolated images,70pixels for green Bayer sites, and140pixels for red and blue Bayer sites. and honestly, aim for edges of at least200pixels for best results on red and blue sites. and yes β see--cfa-patternto specify the Bayer pattern of your raw image. π--cfa-patternrggb|bggr|grbg|gbrgβ picks the Bayer pattern to use whenever the--bayeroption has been specified. the default isrggb, which appears to be the most popular choice amongst DSLRs. iconic of them.--esf-modelkernel|loessβ choose which algorithm MTF Mapper uses to construct the Edge Spread Function (the ESF). theloessalgorithm is the recommended one, unless you're trying to produce results that are compatible with older versions of MTF Mapper (pre-version0.7.16) β and by "compatible" we mean "ahem, roughly similar is more like it". π--single-roiβ treats the entire input image as the region of interest (ROI). this is only intended for small cropped images containing just a single edge β typically when you cropped your ROI out of some larger image. use it if you're doing slanted-edge measurements with a backlit razor blade, or if you're working with an incompatible test chart (like an older ISO 12233 chart). this option has largely superseded the-boption. glow up. β¨--zscalescale-factor β adjusts the minimum value of the z-axis scale of the 3D plots produced with the--surfaceoutput option. a value of0means the z-axis scale starts at zero, and1.0means the z-axis starts from the minimum MTF50 measurement (which really emphasizes those local differences).--logfilefilename β logger output gets written to filename in stead of standard out.--gnuplot-widthpixels β the width of images rendered by gnuplot. typically this affects the output images of--lensprofile,-s, and-p.-b,--borderβ adds a white border of100pixels to the image. might be useful if your image contains only a single black target (a rectangle, say) with a thin white border, or if your image sides clip some of your black test chart targets. but real talk: this option is a kludge to fool MTF Mapper's automatic target detection, so you should not normally need it. also go see--single-roifor the correct way of dealing with single-edge images. π--snap-angleangle β snaps all edge angles to angle. angles get snapped to the closest value modulo 90 degrees, so specifying an angle of4degrees will force edge orientations to one of these:4,-4,86, or94degrees. use this one with care, bestie β it's only appropriate if you're using synthetic images with a known edge orientation. π-gangle,--angleangle β only report MTF50 values on edges with an orientation of angle degrees, in raw output mode (-r).--autocropβ automatically crops the input image to the chart area. the chart is assumed to be brighter than the background, and the automatic cropping will try to remove the darker background. this is mostly meant to speed up processing, and really should only be used if the background area is large compared to the test chart area.--imatest-chartβ automatically crops the input image so that the black bars at the top and bottom of Imatest-style charts (like SFRplus) are suppressed, which lets you fully automatically process all of the square targets found in the chart. you may wanna use a lower threshold value (-t) of0.4or even lower when using--imatest-chart, just to make sure all the square targets get detected. π« and do not use this option with native MTF Mapper test charts.--mtfcontrast β by default MTF Mapper computes MTF50, i.e. the resolution (inlp/mmorcycles/pixel) at which the SFR curve first reaches a contrast of 50%. this option lets you change that target contrast value β compute MTF20, for example. valid contrast values are in the range[10, 90], and they'll be clamped to this range if necessary. this option affects all outputs, including the Annotated image, Profile, Grid and Focus position outputs; only the SFR outputs are unaffected. π--gnuplot-executablefilepath β specify the full path to the gnuplot executable. defaults to/usr/bin/gnuplot, which is usually correct on most Linux distributions.-hβ displays usage information. the classic. π«Ά
π OUTPUT TYPE RELATED OPTIONS π
Alright bestie, this is the glow-up section where you decide what MTF Mapper actually hands back to you. Different outputs, different files, different vibes β pick your fighter π
-a,--annotateβ annotated output mode, iykyk. Turns on Annotate mode and mtf_mapper spits out a file calledannotated.pngwhere every single edge gets annotated with its own MTF50 value. The good-quality edges are annotated in Cyan, and then Yellow and Red annotations mean progressively worse edge quality (usually that's about edge orientation and edge length, lowkey).-s,--surfaceβ surface output mode. This one is on by default β¨ and it generates two output plots: a color-graded 2D view of the MTF50 values all across the image, plus a 3D surface plot of that exact same data. Two plots, one vibe.-p,--profileβ profile output mode. Enables Profile mode, and mtf_mapper produces a plot calledprofile_image.pngshowing a side-view of the MTF50 values. The whole point of this mode is figuring out whether a camera is front-focusing or back-focusing. Heads up: you need a special test chart generated withmtf_generate_test_chartfor this mode to work correctly π«Ά-r,--rawβ raw output mode: it just dumps the MTF50 values into a file calledraw_mtf_values.txt.
NB: the -q output option also produces files containing the MTF50 values, but every entry of that output also gives you the image coordinates of the measurement. Just so you know. π
-e,--esfβ produces edge spread function (ESF) outputs. Every edge corresponds to one row in an output file calledraw_esf_values.txt. Each row contains 256 samples, and those correspond to a window of 32 pixels centered on the edge, oversampled by a factor of 8 β so consecutive samples are 1/8 pixel apart. Fair warning: there is currently no simple way to identify which edge in the input image ends up in a particular row π If your input image contains a single square, then honestly just pick any row, bestie.-f,--sfrβ produces spatial frequency response (SFR) curve outputs. Each edge corresponds to one row in an output file calledraw_sfr_values.txt. Each row starts with the edge orientation (in degrees), followed by 64 values corresponding to the contrast measured at a frequency resolution of 1/64 cycles per pixel. In other words, those 64 values span the frequency range [0,1) cycles per pixel. See-efor advice on matching rows to edges π¦
By default this is an SFR curve, meaning the DC component is always normalized to 1.0. See the --absolute-sfr switch if you want true MTF curves.
NB: the -q output option also produces files containing the SFR curve, but each entry of that output also provides the image coordinates of the measurement. β¨
--absolute-sfrβ do not normalize the SFR curve, i.e., the DC component is not normalized to 1.0. This is useful when you're evaluating the MTF response of algorithms that may reduce overall edge contrast. Very niche, very valid.--nosmoothingβ disables SFR curve (MTF) smoothing. By default MTF Mapper applies Savitzky-Golay filters to the SFR curve to improve its appearance. The only known disadvantage of this smoothing is that the sharp valley surrounding the first zero of the SFR (if present) can be over-smoothed β and in that case the--nosmoothingoption is recommended π―-q,--edgesβ a better choice than either-ror-f, fr fr. This option produces two output files callededge_mtf_values.txtandedge_sfr_values.txt, and both of them combine edge location with the MTF measurement. Iconic behavior.
Each row of the edge_mtf_values.txt file contains six space-separated columns: block_id edge_x edge_y mtf50 corner_x corner_y. The block_id can safely be ignored (it depends on the order in which target squares were processed). The pair (edge_x, edge_y) denotes the pixel coordinates of the centroid of the edge, and mtf50 is the MTF50 value in cycles per pixel (that's the default), or in lp/mm if the --pixelsize option was specified. Lastly, the pair (corner_x, corner_y) denotes the pixel coordinates of the corner of the target (black square) associated with this edge, and can be safely ignored.
The format of the edge_sfr_values.txt file is similar: each row starts with five columns: block_id edge_x edge_y edge_angle radial_angle, followed by 64 more floating point values denoting the SFR. The edge_angle column denotes the orientation of the edge relative to the image rows/columns, modulo 45 degrees. This angle should preferably be at least 2 degrees but less than 44 degrees for best results. The fifth column, radial_angle, is just the angle of the radial line from the image centre to the edge centroid β so you can use it to work out whether an edge is in a Sagittal or Meridional orientation with respect to the image centre, which is assumed to be centered on the test chart. π
The SFR part (those last 64 values on each line of edge_sfr_values.txt) represents the contrast values of the SFR (or MTF, if you prefer) sampled at spatial frequencies of i/64 cycles per pixel for i from 0 to 63 inclusive.
If you use the --full-sfr option together with -q, the SFR component of each line of edge_sfr_values.txt will comprise 128 values (rather than 64), and the corresponding spatial frequencies are i/64 cycles per pixel for i from 0 to 127 inclusive.
NB: the only reliable, safe way to compare the output of MTF Mapper between different images captured using the same camera (say, an f/2.8 vs an f/4 image capture) is to use the pixel coordinates(edge_x, edge_y)of a measurement from image A to find the closest corresponding measurement from image B β assuming you don't move the camera around too much, or rotate the chart or something like that (and in that case you can use the Monkres assignment algorithm to calculate the correct pairing). Please do not rely on the order of the rows of theedge_mtf_values.txtandedge_sfr_values.txtfiles. I am begging you. π
--full-sfrβ outputs the full SFR/MTF curve (up to 2 c/p) when combined with-qor-f. The default is to only output the curve up to 1 c/p. Relatively few cameras have meaningful contrast after 1 c/p, so take note that noise tends to dominate the MTF curve out there π--lensprofileβ this output option produces a Meridional / Sagittal MTF chart similar to those published by lens manufacturers. It requires a lensgrid type MTF Mapper test chart image (but it'll work with older grid style charts too, no cap). The resulting outputlensprofile.pngis a plot of contrast vs radial distance from the centre of the image, at three specified spatial resolutions (see--lp1,--lp2,--lp3). It's recommended that you use the--pixelsizeoption together with--lensprofileso that the units of the chart are in mm for the x-axis, and so that the spatial resolutions are in lp/mm β otherwise the x-axis units are pixels and the spatial resolutions are in c/p, which is not a common choice for this type of chart. Just saying. π§--chart-orientationβ visualizes chart orientation relative to the camera to assist in aligning the camera perpendicular to the chart. This option requires that the input image contains circular fiducial markers (e.g., focus and lensgrid MTF Mapper chart types), and produces an output file calledchart_orientation.pngwhich graphically illustrates the yaw/pitch/roll angles of the test chart relative to the camera. The objective here is to iteratively adjust the chart orientation to bring the yaw and pitch angles as close to zero as possible β preferably below 0.5 degrees β to ensure that the camera's optical axis is perpendicular to the test chart. Once the alignment is satisfactory, other outputs (e.g.,-a, or--lensprofile) can be derived from subsequent images of a lensgrid style chart. For this option to work, the correct lens focal ratio must be specified (see--focal-ratio). π―--focal-ratioratio β specify the focal ratio for use in chart orientation estimation. The focal ratio is computed as focal_length / sensor_width, e.g., 50 mm / 23.6 mm when using a 50 mm lens on an APS-C sized DSLR. This option is only needed if you combine it with the--chart-orientationoption.--lp1resolution,--lp2resolution,--lp3resolution β specify the three spatial resolutions to use when plotting a--lensprofile. Three resolutions, three flags, one gorgeous chart π--focusβ this output type produces a visualization of the peak focus location. A special MTF Mapper chart type is required (focus), which should be imaged at a 45-degree tilt with respect to the camera. This chart is not suitable for use with camera autofocus; rather, it's intended to calibrate a manual focus lens, or to measure focus shift in a lens. Please see the MTF Mapper user guide for more information.
NB: note that the--focusoutput option is incompatible with most other output options (e.g.,-a,-s,--lensgrid,-q, etc.), so do not use this option unless you are sure you want to. Like, sure sure. π
--mfprofileβ this output type produces a visualization of the curve formed by the intersection of the "surface of best focus" and the test chart. A special MTF Mapper chart type is required (mfperspective), which should be imaged at a 45-degree tilt with respect to the camera. This chart is intended for manual focus operation since the chart does not contain suitable central features for autofocus operation.
NB: note that the--mfprofileoutput option is incompatible with most other output options (e.g.,-a,-s,--lensgrid,-q, etc.), so do not use this option unless you are sure you want to. Same energy as above, bestie. π«Ά
π LENS DISTORTION RELATED OPTIONS π
ok so this whole section is about the fact that lenses are, like, dramatic and bend light in ways that are not a vibe. read on bestie π
--esf-samplerline|quadratic|piecewise-quadratic|deferred β picks which approximation models the curve of your image edges. the default ispiecewise-quadratic, okay? now listen:- if your image has absolutely no radial lens distortion, then
lineis optimal. like, that's her moment. quadraticandpiecewise-quadraticdo exactly what their names say (iconic of them): the straight edges of the target objects on the test chart β which we're assuming are straight β get modelled with a (piecewise-) quadratic curve.deferredis a special girl: she's only available when you've specified an overall lens distortion model using--equiangular,--stereographic, or--optimize-distortion. and heads up π«Ά selecting any one of those options automatically forces--esf-sampler=deferred.
- if your image has absolutely no radial lens distortion, then
--stereographicfocal length(mm) β treat the input image as a stereographic mapping (fisheye, bestie π) with the focal length you give, in mm. with this option, the annotated output image (that's output option-a) will be unmapped, i.e. in its rectilinear equivalent mapping β but the MTF measurements are still made in the original (distorted) image. also: this option requires a pixel pitch to be specified using the--pixelsizeoption. no pixelsize, no party.--equiangularfocal length(mm) β same energy, different mapping: treat input image as an equi-angular mapping (fisheye) with the specified focal length in mm. with this one too, the annotated output image (output option-a) will be unmapped, i.e. in its rectilinear equivalent mapping, but MTF measurements are still made in the original (distorted) image. and yep, this option also requires a pixel pitch specified using the--pixelsizeoption. π--optimize-distortionβ this one's a whole two-step process to compensate for radial lens distortion:- a two-parameter division model gets fitted, so you get a distortion model of the lens
- then MTF measurements happen in the original (distorted) image, but using the undistorted image to guide the process
the annotated output image (output option -a) is based on the undistorted image. this option works best when the test chart β preferrably the lensgrid chart β fills the frame, and the average edge length is 200 pixels or more. she likes a full frame, what can I say π
note that this option can, in practice, replace the use of the--stereographicand--equiangularundistortion methods.
also note: it is not necessary to undistort the image (to produce straight target edges) to obtain accurate MTF measurements. by default, MTF Mapper now uses a piecewise-quadratic curve to model target edges, so those three undistortion methods (--stereographic, --equiangular, and --optimize-distortion) are mostly for research purposes now. sorry to the researchers, ilysm π§
--no-undistort-cropβ by default, MTF Mapper estimates which part of the undistorted image is actually usable, i.e. not stretched too much, and crops the output accordingly. this option overrides that cropping when used with the--equiangularand--stereographicoptions.
β οΈ this can produce very large output images, so use with care. like, your disk said please π
π― SEE ALSO π―
the besties, the girlies, the whole friend group:
mtf_generate_rectanglemtf_generate_test_chartmtf_mapper_gui
π«Ά AUTHOR π«Ά
Frans van den Bergh <fvdbergh@gmail.com> β Author.
and that's the whole page, bestie!! π you just read the full MTF_MAPPER(1) manual β from this release, dated 05/09/2026 β and honestly? slay. go measure some MTF, you absolute icon πβ¨πΈ
π¦ where this page comes from
- ubuntu stonking: mtfmapper 0.7.41-2 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms