利用Matlab Toolbox工具箱下载图像库
一、下载Matlab Toolbox工具箱
We maintain the latest version of the toolbox on github. To pull the latest version, make sure that "git" is installed on your machine and then run "git clone https://github.com/CSAILVision/LabelMeToolbox.git" on the command line. You can refresh your copy to the latest version by running "git pull" from inside the project directory.
The zip file is a snapshot of the latest source code on github.
二、下载图像库
There are two ways to work with the dataset: (1) downloading all the images via the LabelMe Matlab toolbox. The toolbox will allow you to customize the portion of the database that you want to download, (2) Using the images online via the LabelMe Matlab toolbox. This option is less preferred as it will be slower, but it will allow you to explore the dataset before downloading it. Once you have installed the database, you can use the LabelMe Matlab toolbox to read the annotation files and query the images to extract specific objects.
Before downloading the dataset, we only ask you to label some images using the annotation tool online. Any new labels that you will add, will be inmediately ready for download.
Step 1: Download the LabelMe Matlab toolbox and add the toolbox to the Matlab path.
Step 2: The function LMinstall will download the database. There are three ways to use this function:
HOMEIMAGES = '/desired/path/to/Images';
HOMEANNOTATIONS = '/desired/path/to/Annotations';
LMinstall (HOMEIMAGES, HOMEANNOTATIONS);
where "/desired/path/to/" is the desired location where the annotations and images will be stored.
This process will create the following directory structure under "/desired/path/to/":
./Annotations
./Annotations/folder1
...
./Annotations/folderN
./Images
./Images/folder1
...
./Images/folderN
where folder1 through folderN are directories containing the images and annotations.
HOMEIMAGES = '/desired/path/to/Images';
HOMEANNOTATIONS = '/desired/path/to/Annotations';
folderlist = {'05june05_static_street_porter'};
LMinstall (folderlist, HOMEIMAGES, HOMEANNOTATIONS);
This will download only one folder from the collection. You can see the complete list of folders here.
LMinstall (folders, images, HOMEIMAGES, HOMEANNOTATIONS);
Before downloading the dataset, we only ask you to label some images using the annotation tool online. Any new labels that you will add, will be inmediately ready for download. If you use the LabelMe Matlab toolbox, it is not necesary to download the database. You can use the online images and annotations in the same way as if they were on your local hard drive. This might be slow, but it will let you explore the database before downloading it. If you plan to use the database extensively, it is better to download a local copy for yourself. Here are a few Matlab commands that show how to use the online database:
HOMEIMAGES = 'http://people.csail.mit.edu/brussell/research/LabelMe/Images';
HOMEANNOTATIONS = 'http://people.csail.mit.edu/brussell/research/LabelMe/Annotations';
D = LMdatabase(HOMEANNOTATIONS); % This will build an index, which will take few minutes.
% Now you can visualize the images
LMplot(D, 1, HOMEIMAGES);
% Or read an image
[annotation, img] = LMread(D, 1, HOMEIMAGES);
You can query the database to select the images you want and install only those ones. For instance, if you are interested only in images containing cars, you can run the following:
% First create the list of images that you want:
[Q,j] = LMquery(D, 'object.name', 'car');
clear folderlist filelist
for i = 1:length(Q);
folderlist{i} = Q(i).annotation.folder;
filelist{i} = Q(i).annotation.filename;
end
% Install the selected images:
HOMEIMAGES = '/desired/path/to/Images';
HOMEANNOTATIONS = '/desired/path/to/Annotations';
LMinstall (folderlist, filelist, HOMEIMAGES, HOMEANNOTATIONS);
参考:
[1] http://labelme.csail.mit.edu/Release3.0/browserTools/php/matlab_toolbox.php
[2] http://labelme.csail.mit.edu/Release3.0/browserTools/php/dataset.php