MATLAB codes to import or read multiples data and plot it on multiple images simultaneously

3 visualizaciones (últimos 30 días)
I have a folder that contain about 120 face images with their coordinates in txt formats. I need a matlab code that can read or import each of the coordinates and plot it on a face images. E.g, read or import coordinates for image 1 and plot it on image 1, then read or import coordinates for images 2 and plot it on image 2 and so on till the end. I can do it for individual images but i want a code that can do all at once simultaneously (read/import and plot, read/import and plot). Please help. An example of the coordinates in txt format is shown below. To see the data better, i have uploaded the a sample of the data file in txt format. (1-1.txt)
X Y 0.35763609 0.64077979 0.36267641 0.68243247 0.3747732 0.72945964 0.39896673 0.78051776 0.42215222 0.81679589 0.4594506 0.84769946 0.4907006 0.85441762 0.53707159 0.83963764 0.56428933 0.81007773 0.58243448 0.77245593 0.59755546 0.72811604 0.60763609 0.6904943 0.61469257 0.65018529 0.5844506 0.50776005 0.56932962 0.49298009 0.5532006 0.48760554 0.5310232 0.49029282 0.5229587 0.50641644 0.54110384 0.51179093 0.55622482 0.51582187 0.57235384 0.51582187 0.39291835 0.50507277 0.41106352 0.48894918 0.43021673 0.48088738 0.4483619 0.49163646 0.46449092 0.50507277 0.44634578 0.51044732 0.4282006 0.51179093 0.41005543 0.50910372 0.50783771 0.47551286 0.52094257 0.44864017 0.57336187 0.4378911 0.60561997 0.45670196 0.61166835 0.50238556 0.47658771 0.47282559 0.45743448 0.44460928 0.40501511 0.43386021 0.37578124 0.44864017 0.36973286 0.49298009 0.43424898 0.69452518 0.47658771 0.68646336 0.48969254 0.69452518 0.50279737 0.68511975 0.54513609 0.68646336 0.50884575 0.72408509 0.4907006 0.72542876 0.47255543 0.72408509 0.47457156 0.50910372 0.47557965 0.56016177 0.45340222 0.59240901 0.45138609 0.6246562 0.4685232 0.63271803 0.4907006 0.63137436 0.51388609 0.63271803 0.52900708 0.61525077 0.52094257 0.58569086 0.50884575 0.56150544 0.50682962 0.51179093
  2 comentarios
Jan
Jan el 1 de Jul. de 2018
There is no chance to reconstruct a "face" based on the example data you gave us. The meaning of the values has not been defined. Are these points?
What have you tried so far?
Abdulmu'min Musa
Abdulmu'min Musa el 1 de Jul. de 2018
Editada: Abdulmu'min Musa el 1 de Jul. de 2018
Yes, these are points. I have tried reading multiples face images at once, which works. I have tried importing data from a file and plotting it on a face, which also works. What i want now is to read/import all the data and be plotting on the face individually simultaneously. A code that will read all the images with the points plotted on them. I have also attach upload the a sample of the data in .txt format.

Iniciar sesión para comentar.

Respuestas (1)

Paolo
Paolo el 1 de Jul. de 2018
Editada: Paolo el 1 de Jul. de 2018
If I understand correctly, you want to process multiple text files which contain X,Y coordinates. Try:
files = dir('*.txt');
nfiles = numel(files);
yourdata = cell(1,nfiles);
for i=1:nfiles
fileID = fopen(files(i).name);
yourdata{1,i} = textscan(fileID,'%f%f','HeaderLines',1);
fclose(fileID);
end
yourdata is a cell array, where every cell contains X and Y data from each .txt file. You may then use the data for plotting.
for i=1:nfiles
figure
plot(yourdata{i}{1}, yourdata{i}{2});
end

Community Treasure Hunt

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

Start Hunting!

Translated by