urgent help here please... trying to change the file name on this code on each instance of running the function
f=imread('Plate_7.jpg'); % Reading the number plate image file
i want the 'Plate_1' to increment by 1 each time the program runs to 'Plate_2', 'Plate_3'... and so on!
i have tried using a for loop
for k=1:10
file=sprintf('Plate_%d.jpg',k)
f=imread('Plate.jpg'); % Reading the number plate image file
end
but this just lists image 1 up to 10 in the command window...

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 15 de Abr. de 2014
Editada: Azzi Abdelmalek el 15 de Abr. de 2014
for k=1:10
file=sprintf('Plate_%d.jpg',k)
f{k}=imread(file);
end

4 comentarios

Nakk Mungofa
Nakk Mungofa el 15 de Abr. de 2014
thanks so much!!! seems to be working
Nakk Mungofa
Nakk Mungofa el 15 de Abr. de 2014
ohhh just one problem now though, i first save an image with base name "Plate_"... so this is also incrementing, so wen f{k}=imread(file) reads from file it looks for Plate_2 wen only Plate_1 has just been saved...
Azzi Abdelmalek
Azzi Abdelmalek el 15 de Abr. de 2014
What do you mean?
Nakk Mungofa
Nakk Mungofa el 15 de Abr. de 2014
here is the section of code im dealing with:
%save image
counter = 1;
baseDir = 'C:\Users\Nakk\Documents\zvanhasi\Number_Plate_Extraction\';
baseName = 'Plate_';
newName = fullfile(baseDir, sprintf('%s%d.jpg', baseName, counter));
while exist(newName,'file')
counter = counter + 1;
newName = fullfile(baseDir, sprintf('%s%d.jpg', baseName, counter));
end
imwrite(img, newName);
for k=1:10
file=sprintf('Plate_%d.jpg',k);
f{k}=imread(file);
end
it gives
Error using imread (line 368)
File "Plate_2.jpg" does not exist.
soon after it saves "Plate_1"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 15 de Abr. de 2014

Comentada:

el 15 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by