help to assign correct image path to a variable

14 visualizaciones (últimos 30 días)
harpreet
harpreet el 18 de Mayo de 2015
Comentada: harpreet el 19 de Mayo de 2015
% dataset
DB = 'MICC-F220';
db_dir ='dataset';
file_ground_truth = 'groundtruthDB_220.txt';
% parameters
metric = 'ward';
th = 2.2;
min_pts = 4;
% load ground truth from a file
[ImageName, GT] = textscan(fullfile(db_dir,DB,file_ground_truth), '%s %d');
num_images = size(ImageName,1);
fid_gt = fopen(fullfile(db_dir,DB,file_ground_truth));
C = textscan(fid_gt, '%s %u');
fclose(fid_gt);
TP = 0; % True Positive
TN = 0; % True Negative
FP = 0; % False Positive
FN = 0; % False Negative
for i = 1:220
%parfor i = 1:num_images % use for parallel computation (needs matlabpool)
loc_file = fullfile(db_dir,DB,cell2mat(ImageName{i}));
name = cell2mat(ImageName{i});
% process an image
fprintf('Processing: %s (%d/%d)\n',loc_file,i,num_images);
countTrasfGeom = process_image(loc_file, metric, th, min_pts, 0);
% tampering detection
dim_v=size(C{1,1});
for l=1:dim_v(1,1)
if isequal(C{1,1}{l},ImageName{i})
index=l;
end
end
if countTrasfGeom>=1
if C{1,2}(index)
TP = TP+1;
else
FP = FP+1;
end
else
if C{1,2}(index)
FN = FN+1;
else
TN = TN+1;
end
end
end
% compute performance
FPR = FP/(FP+TN);
TPR = TP/(TP+FN);
fprintf('\nCopy-Move Forgery Detection performance:\n');
fprintf('\nTPR = %1.2f%%\nFPR = %1.2f%%\n', TPR*100, FPR*100);
% compute computational time
tproc = toc(tstart);
tps = datestr(datenum(0,0,0,0,0,tproc),'HH:MM:SS');
fprintf('\nComputational time: %s\n', tps);
Above is the script for processing a single image from a complete dataset of images. But on running the above code, following error is received:
Error using imread (line 350)
File "dataset\MICC-F220\dataset\MICC-F220\groundtruthDB_220.txt" does not exist.
Error in process_image (line 48)
image1 = imread(imagefile);
Error in run_F220_experiment (line 35)
countTrasfGeom = process_image(loc_file, metric, th, min_pts, 0);
It clearly indicates that the variable named 'loc_file' in the above script has not been assigned a image correctly. It is also mentioned here that when we run the command given below in command window:
loc_file = fullfile(db_dir,DB,cell2mat(ImageName{i}));
the following result comes up:
loc_file =
dataset\MICC-F220\dataset\MICC-F220\groundtruthDB_220.txt
Which clearly indicates, loc_file has not been assigned correct path of the image. Kindly suggest modifications..
  2 comentarios
Image Analyst
Image Analyst el 18 de Mayo de 2015
What is the value of "imagefile"? Is it a string with the name of a .txt file, or a valid image file?
harpreet
harpreet el 19 de Mayo de 2015
Sir, Although image file must be an image according to the syntax. But it depends upon the argument passed to the function- process-image, i.e. loc_file. Hence, loc_file must hold an image. But as the error shows, it is getting incorrect path means path is getting duplicated like: "dataset\MICC-F220\dataset\MICC-F220\groundtruthDB_220.txt"
P.s. the file groundtruth.txt contains names of all the images in the dataset on which experiment needs to be run.

Iniciar sesión para comentar.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 18 de Mayo de 2015
I think it needs to be '.\' at the beginning of the filename to specify relative path.
.\dataset\MICC-F220\dataset\MICC-F220\groundtruthDB_220.txt

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by