computer vision - How to provide input to BagOfFeatures() function in MATLAB in the form of imageSet or imageDataStore? -
i want use bagoffeatures() function of matlab. requires input in form of imageset or imagedatastore. code want run given below:
dataset = 'd:\dsktop\kinect_leap_dataset\acquisitions'; thresh1 = 0; thresh2 = 20; k = dir(fullfile(dataset,'\p*\g*\*_depth.png')); kf = {k(~[k.isdir]).folder}; kn = {k(~[k.isdir]).name}; j=1:length(k) % applying thresholding original image full_name = horzcat(kf{j},filesep,kn{j}); image = imread(full_name); image_bin1 = (image < thresh2); image_bin2 = (thresh1 < image); image_bin = abs(image_bin2- image_bin1); sequence{i} = image_bin; end % bag of features bag = bagoffeatures(sequence); but "sequence" cell class , bagoffeatures() giving me errors. tried this:
dataset = 'd:\dsktop\kinect_leap_dataset\acquisitions'; imgfolder = fullfile(dataset); imgsets = imageset(imgfolder, 'recursive'); imgsets.description but problem how processing (thresholding) on images saved in imgsets. also, after processing how save "image_bin" images in imageset class can give them input bagoffeatures() function.
i solved problem myself. give input imageset or imagestrore bagoffeatures(), have store "image_bin" images in folder in pc. that, have create folder in desired location as
mkdir d:\.............\cropped then, have save "image_bin" in folder in loop as
file_name = sprintf('d:/............/cropped/image_bin_%d.png',j); imwrite(image_bin, file_name); then, data above folder read in matlab memory as
imds = imagedatastore('d:/.............../cropped', 'labels', label); % label array of labels made user [trainingset, validationset] = spliteachlabel(imds, 0.3, 'randomize'); % bag of features bag = bagoffeatures(trainingset); and it's done.
Comments
Post a Comment