main executing reference usage: usage_ImageToAndFromGraphCoordinates.m
The objective is to illustrate how to map a 2-level image, ie. black-and-white image, to graph coordinates and vice-versa.
* Caveat: For demo reference only.
- Certain conditions are also to be noted, please refer to notes at the demo codes.
If the demo has a more elegant presentation, please do not hesitate to suggest and send feedback to author.
Michael Chan JT
Could you make one version that map fingerprint images to X-Y coordinates? I have sent some programs to your email. Please help me for the project.
Poorly written, and with no clear purpose.
Although the example illustration shows black/dark pixel detection using this function with a neat plot of the detected pixel locations, the non-existent documentation conveniently does not mention that this only works for indexed image data, and only then if the second color index (1) happens to correlate to the pixel color of interest. Users who try to use this function with their existing image data, or import images as RGB or grayscale, will be sorely disappointed by the two empty vectors that this function will return. Or might find that the function detects all white pixels instead. The non-existent documentation sadly does not mention minor details like this.
The absent help also does not explain the purpose of the four arguments <upperRangeX>, <lowerRangeX>, <lowerRangeY>, <upperRangeY>: are these to select a part of my input image, or to scale the output data, or, just like the internal variables <x_plot_min>, <x_plot_max>, <y_plot_min> and <y_plot_max>, simply remain completely unused? Luckily MATLAB includes the "mlint" function, which easily and quickly allows checking for basic coding mistakes like this: use of "mlint" is recommended before uploading onto FEX.
The author does make the comment "Caveat: For demo reference only". This is certainly true, as without any documentation, input checking or error messages the user is forced to waste considerable time trying to figure out what this submission does. The lack of constructive comments makes the purpose of interestingly named variables, such as <pixeliZedScratchPad>, somewhat opaque (answer: this is the image data). If it is intended as a reference, then the lack of any helpful explanations, reasoning or justifications leaves the user to make up their own mind about the code.
The file "usage_ImageToAndFromGraphCooridinates.m" calls <close all; clear all; clc;> at the top of the script which removes all variables in the workspace: some might consider this to be a bit impolite. It is certainly bad practice for a FEX submission, as has been explained and discussed many times before on FEX.
The overall impression is that this is someone's homework attempt, but hardly something that is suitable for submission on FEX. For those who require this functionality, the submission essentially does this:
% Read data from a B&W, RGB or indexed image file:
[A,map] = imread(imagefile);
% Convert indexed to RGB:
A = ind2rgb(A,map);
% Find the black pixels:
[Y,X] = find(0==mean(A,3));
% Plot (inverting Y-axis):