Code covered by the BSD License  

Highlights from
Convert Image To And From Graph Coordinates

2.66667

2.7 | 3 ratings Rate this file 24 Downloads (last 30 days) File Size: 53 KB File ID: #29598
image thumbnail

Convert Image To And From Graph Coordinates

by

 

02 Dec 2010 (Updated )

Illustrates mapping of binary image to graph coordinates and vice-versa.

| Watch this File

File Information
Description

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.
Email: promethevx@yahoo.com.

Thank you.

Regards,
Michael Chan JT

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
15 Aug 2014 Joan

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.

14 Aug 2014 Stephen Cobeldick

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:
if ~isempty(map)
A = ind2rgb(A,map);
end
% Find the black pixels:
[Y,X] = find(0==mean(A,3));
% Plot (inverting Y-axis):
plot(X,1+max(Y(:))-Y,'*')

16 Dec 2013 sibasish dutta  
Updates
30 Jun 2014

pixeliZedScratchPad.mat added.

Contact us