Saving images into various folders

1 Ansicht (letzte 30 Tage)
Abhishek Singh
Abhishek Singh am 19 Jul. 2019
Kommentiert: KALYAN ACHARJYA am 19 Jul. 2019
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.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 19 Jul. 2019
Bearbeitet: KALYAN ACHARJYA am 19 Jul. 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 Kommentare
Abhishek Singh
Abhishek Singh am 19 Jul. 2019
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?
KALYAN ACHARJYA
KALYAN ACHARJYA am 19 Jul. 2019
Yes

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by