Extracting Raw Data From an Image in MATLAB

November 12th, 2008 matt Posted in Random 1 Comment »

I was going through some old code and ran across this little gem of a MATLAB script, so I thought I’d post it here for posterity. 

The script lets you specify an image file to view and lets you click on each data point until you’re finished.  Then it exports the (x,y) coordinates of all of the points that you clicked.  This is indispensable if you have a graph from a paper that you would like to analyze further but don’t have the original data file.

% digitize.m
function [x,y] = digitize(imgname)

[img,map] = imread(imgname);
image(img);
colormap(map);

Left = input('Enter the left X coordinate: ');
Right = input('Enter the right X coordinate: ');
Bottom = input('Enter the bottom Y coordinate: ');
Top = input('Enter the top Y coordinate: ');

disp('Click on the lower-left corner');
[localLeft,localBottom] = ginput(1);
disp('Click on the upper-right corner');
[localRight,localTop] = ginput(1);

disp('Begin digitizing points. Click right mouse button when finished.');
b = 0; bold = 0;
while(b~=3)
   [xp,yp,b] = ginput(1);
   if (b == 1)
      if (bold ~= 0)
         line([xold; xp], [yold; yp]);
         x = [x; xp];
         y = [y; yp];
      else
         x = xp;
         y = yp;
      end
      xold = xp; yold = yp; bold = b;
   end
end

x = (x - localLeft) / (localRight-localLeft) * (Right-Left) + Left;
y = (y - localBottom) / (localTop - localBottom) * (Top-Bottom) + Bottom;

Credit goes to Brian Usner, wherever you are :)

AddThis Social Bookmark Button

Not As Secure As It Could Be?

October 14th, 2008 matt Posted in Random No Comments »

I was cleaning off my desktop and ran across this gem that I’d snagged when I was registering my copy of MATLAB:

letters_and_digits_only

Hmm, that’s interesting. Just make potential dictionary attacks a little easier, since the dictionary space is smaller.  (But, then again, who would want to brute-force a Mathworks account anyway?)

On the other hand, perhaps this could be more secure (especially if they increase the required password length), since the elimination of all "strange characters" limits the potential of SQL injection attacks.

AddThis Social Bookmark Button