Problem in creating image database file.

3 views (last 30 days)
Sam
Sam on 13 May 2016
Commented: Walter Roberson on 13 May 2016
Hi,
I am trying to code face key points detector using Matlab using NN toolbox. Training text file is of form (string path of face image followed by 4 integers-bounding box):
foldername\filename_0001.jpg 84 92 161 169
5000 rows like this.
How do I create mat file of this cropped face images and pass on as input to network?

Answers (1)

Walter Roberson
Walter Roberson on 13 May 2016
You would imread() each, imcrop(), reshape as a vector, add it to a column to a matrix you are building up. The completed matrix would be passed as the inputs for the neural network.
  2 Comments
Sam
Sam on 13 May 2016
Edited: Walter Roberson on 13 May 2016
thanks for the reply, I need little more help now.
problem is after cropping i need to resize it to 39x39.
but my target (x,y)face points are give in original image dimensions(250x250).
how to rescale it to proper values after cropping and resizing for NN target i/p for training?
here is my code,
clear all;close all;
load('jpgfiletrain_short.mat');% loading cell imdata{} that contains 4 images
fileID = fopen('trainImageList_short.txt');
% 4 %u's are square bound box (x,y) pair that vary in size, 10 %f's are 5 (x,y) pair of 2 eye
% centers, 1 nose tip and 2 mouth corners...
C = textscan(fileID,'%s %u %u %u %u %f %f %f %f %f %f %f %f %f %f');
fclose(fileID);
% celldisp(C)
for k=1:4
cropdata{k}= imcrop(rgb2gray(imdata{k}),[C{2}(k) C{4}(k) C{3}(k)-C{2}(k) C{5}(k)-C{4}(k)]);
rszdata{k} = imresize(cropdata{k}, [39 39]);
target(:,k)=[C{6}(k) C{7}(k) C{8}(k) C{9}(k) C{10}(k) C{11}(k) C{12}(k) C{13}(k) C{14}(k) C{15}(k)];
end

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!