Code covered by the BSD License  

Highlights from
LABEL ME

LABEL ME

by

 

MANUALLY LABELING IMAGE REGIONS BY SELECTING RECTANGLES

labelme.m
% LABELME 
% Allows users to create a draggable rectangle for selecting objects in
% images and saves the coordinates in a file (for multiple such rectangles)

% USAGE
% Select an image file to open. Start selecting draggable rectangles. Double-click
% to save the coordinates. When done, double-click at a single point in the image to terminate.

% INPUT
% Interactive GUI that can be used to select a file. 

% OUTPUT
% Saves a textfile with the same name as imagefile containing the rectangle
% coordinates. 

% Copyright (c) 2011 Vidya Murali
% Coughlan Lab
% Smith Kettlewell Eye Research Institute
% http://www.ski.org/Rehab/Coughlan_lab/General/VidyaMurali.html
% 
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, subject to the following conditions:
% 
% The above copyright notice and this permission notice shall be included in 
% all copies or substantial portions of the Software.
%
% The Software is provided "as is", without warranty of any kind.

% Feb 2012    - Original version
%----------------------------------------------%

[fname pathname]=uigetfile;
str1 = strcat(pathname,'');
str1=strcat(str1,fname);
str2=regexprep(str1,'bmp','txt');
str2=regexprep(str1,'jpg','txt');
str2=regexprep(str1,'JPG','txt');

str=strcat(pathname,fname);
fpt=fopen(str2,'w');
im = imread(str);
figure(1);
while(1)
    imshow(im);
    h=imrect; position=wait(h);
    area=position(3)*position(4);
    if(area <1 ) break; end
    fprintf(fpt,'%d %d %d %d \n',position(1),position(2),position(3),position(4)); % x,y,width,height   
end
fclose(fpt);
close all;

Contact us