Code covered by the BSD License  

Highlights from
LABEL ME

LABEL ME

by

 

Selects and saves rectangle for labeling objects in images

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
% 

% 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