Saving images into various folders

1 次查看(过去 30 天)
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.

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-7-19
编辑:KALYAN ACHARJYA 2019-7-19
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 个评论
Abhishek Singh
Abhishek Singh 2019-7-19
I can understand that, but don't you think referring images directly by calling my cluster{} function and then it saves them to the system since all are present in workspace would be faster?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by