Saving images into various folders
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am working on image clustering. My algorithm reads the image set from my system into MATLAB and segregates them into different clusters based on my criteria. At the end of the algorithm I have different cluster numbers with their image index content. So if I have cluster 1 with images 1,2,3,5 for example:- Cluster{1} would return a matrix.
Cluster{1} 1 2 3 5
I was wondering if I could use some function which saves those image according to the clusters in my local machine. For example, if I have image (1,2,3,5) in cluster 1 and image (4,7) in cluster 2 then I should have two folders in my working directory named Cluster1 with image 1 2 3 5 and Cluster 2 with image 4 7. I am right now trying to include for() loop by looking at each content of each cluster{}. I tried just reading and writing the same image and it took a couple of seconds which led me to believe the loop will even slower it down. Could someone please tell me the Matrix way to do it which would be faster than this.
Please let me know if this could be achieved. Thank you in advance.
0 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 19 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 19 de Jul. de 2019
Original Question
"I am working on image clustering. My algorithm reads the image set from my system into MATLAB and segregates them into different clusters based on my criteria. At the end of the algorithm I have different cluster numbers with their image index content. I was wondering if I could use some function which saves those image according to the clusters in my local machine. For example, if I have image (1,2,3,5) in cluster 1 and image (4,7) in cluster 2 then I should have two folders in my working directory named Cluster1 with image 1 2 3 5 and Cluster 2 with image 4 7.
Please let me know if this could be achieved. Thank you in advance"
You can do this way also
Images=input images path
outDirectory1='C:\complete_path\cluster1\';
outDirectory2='C:\complete_path\cluster2\';
for i=1:.... % Image read iterration
%% Save Images
if segmented_image condition for_cluster 1 or cluster 2
%or Check from i
if cluster1
imwrite(segmented_image,strcat(outDirectory1,Images(i).name));
else %(This for cluster2)
imwrite(segmented_image,strcat(outDirectory2,Images(i).name));
end
Please Note: May be there is more easier way.
7 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!