From: agnes cawas on
I do clustering image with k-means...I had extracted the feature into txt file every feature of image with some number of array, but i dont know how to process to cluster all files extraction..help me please!!!
From: ImageAnalyst on
On Jul 28, 11:55 pm, "agnes cawas" <o_nestblu...(a)yahoo.com> wrote:
> I do clustering image with k-means...I had extracted the feature into txt file every feature of image with some number of array, but i dont know how to process to cluster all files extraction..help me please!!!

--------------------------------------------------------------
I don't know either, since I can't really understand exactly what
you're asking. Did you see the Mathworks demo on this:
http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html
From: agnes cawas on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <464d6e90-af04-4fe4-8f2d-2f3024180bf4(a)t2g2000yqe.googlegroups.com>...
> On Jul 28, 11:55 pm, "agnes cawas" <o_nestblu...(a)yahoo.com> wrote:
> > I do clustering image with k-means...I had extracted the feature into txt file every feature of image with some number of array, but i dont know how to process to cluster all files extraction..help me please!!!
>
> --------------------------------------------------------------
> I don't know either, since I can't really understand exactly what
> you're asking. Did you see the Mathworks demo on this:
> http://www.mathworks.com/products/demos/image/color_seg_k/ipexhistology.html



i want to cluster images. I have extracted those images n saved in text file. so,if there 50 images, there will be 50 file text extraction..the problem is,I don't know how to process those file text to be clustered?
do you get what I mean?
From: ImageAnalyst on
On Jul 31, 4:01 am, "agnes cawas" <o_nestblu...(a)yahoo.com> wrote:
> i want to cluster images. I have extracted those images n saved in text file. so,if there 50 images, there will be 50 file text extraction..the problem is,I don't know how to process those file text to be clustered?
> do you get what I mean?
---------------------------------------------------------------
agnes:
Sorry, but no, I don't understand. What does it mean to extract
images into text files? Do you mean that you converted the image
values into text strings? Like a gray level of 123 stored in binary
uint8 format in your image would then be either "123" or "49" "50"
"51" (the ASCII values of 123) in a text file? This makes no sense to
me.

And what does "cluster images" mean? Does that mean like you'd want
to have, say, 6 clusters where you cluster on dominant color, like
"reddish images," "greenish images," "bluish images," "brownish
images," "whitish images," and "purplish images"??? And what would
that have to do with writing these images out as text???

From: agnes cawas on
function Extractfeature()

%ekstraksi tepi

dirAsl = {'data_1'; 'data_2';};

for x = 1:length(dirAsl)
cd(dirAsl{x});
fileGambar = dir ('*.jpg');
jumlahGambar = length(fileGambar);

for y =1:length(fileGambar)
batik = imread(fileGambar(y).name); % baca citra
ting=size(batik,1); % hitung tinggi citra
lbr=size(batik,2); % hitung lebar citra

sum1=0; sum2=0; sum3=0; sum4=0; sum5=0; sum6=0; sum7=0; sum8=0; % penghitung kepadatan
sum9=0; sum10=0; sum11=0; sum12=0; sum13=0; sum14=0; sum15=0; sum16=0;
sum17=0; sum18=0; sum19=0; sum20=0; sum21=0; sum22=0; sum23=0; sum24=0;
sum25=0; sum26=0; sum27=0; sum28=0; sum29=0; sum30=0; sum31=0; sum32=0;
sum33=0; sum34=0; sum35=0; sum36=0; sum37=0; sum38=0; sum39=0; sum40=0;
sum41=0; sum42=0; sum43=0; sum44=0; sum45=0; sum46=0; sum47=0; sum48=0;
sum49=0; sum50=0; sum51=0; sum52=0; sum53=0; sum54=0; sum55=0; sum56=0;
sum57=0; sum58=0; sum59=0; sum60=0; sum61=0; sum62=0; sum63=0; sum64=0;
putih = 1;
feature=[]; % matriks info kepadatan piksel

dR = batik(:,:,1);
dG = batik(:,:,2);
dB = batik(:,:,3);
meanR = mean(mean(dR));
meanG = mean(mean(dG));
meanB = mean(mean(dB));
kadarR = meanR/(meanR + meanG + meanB);
kadarG = meanG/(meanR+meanG+meanB);
kadarB = meanB/(meanR+meanG+meanB);
meanRGB = (meanR+meanG+meanB)/3;

BW =rgb2gray(batik);
tepiGambar = edge(BW,'canny');


for a =1:25
for b = 1:25
if(tepiGambar(a,b) == putih) sum1 = sum1+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum2 = sum2+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum3 = sum3+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)== putih) sum4 = sum4+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)==putih) sum5 = sum5+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum6 = sum6+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum7 = sum7+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum8 = sum8+1;
end
end

end
mean1 = sum1/625; mean2 = sum2/625; mean3 = sum3/625; mean4 = sum4/625;
mean5 = sum5/625; mean6 = sum6/625; mean7 = sum7/625; mean8 = sum8/625;


for a =26:50
for b = 1:25
if(tepiGambar(a,b) == putih) sum9 = sum9+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum10 = sum10+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum11 = sum11+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)==putih) sum12 = sum12+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)==putih) sum13 = sum13+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum14 = sum14+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum15 = sum15+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum16 = sum16+1;
end
end
end
mean9 = sum9/625; mean10 = sum10/625; mean11 = sum11/625; mean12 = sum12/625;
mean13 = sum13/625; mean14 = sum14/625; mean15 = sum15/625; mean16 = sum16/625;


for a =51:75
for b = 1:25
if(tepiGambar(a,b) == putih) sum17 = sum17+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum18 = sum18+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum19 = sum19+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)==putih) sum20 = sum20+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)==putih) sum21 = sum21+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum22 = sum22+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) ==putih) sum23 = sum23+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum24 = sum24+1;
end
end
end
mean17 = sum17/625; mean18 = sum18/625; mean19 = sum19/625; mean20 = sum20/625;
mean21 = sum21/625; mean22 = sum22/625; mean23 = sum23/625; mean24 = sum24/625;


for a =76:100
for b = 1:25
if(tepiGambar(a,b) == putih) sum25 = sum25+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum26 = sum26+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum27 = sum27+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)== putih) sum28 = sum28+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)== putih) sum29 = sum29+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum30 = sum30+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum31 = sum31+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum32 = sum32+1;
end
end
end
mean25 = sum25/625; mean26 = sum26/625; mean27 = sum27/625; mean28 = sum28/625;
mean29 = sum29/625; mean30 = sum30/625; mean31 = sum31/625; mean32 = sum32/625;



for a =101:125
for b = 1:25
if(tepiGambar(a,b) == putih) sum33 = sum33+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum34 = sum34+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum35 = sum35+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)== putih) sum36 = sum36+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)== putih) sum37 = sum37+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum38 = sum38+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum39 = sum39+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum40 = sum40+1;
end
end
end
mean33 = sum33/625; mean34 = sum34/625; mean35 = sum35/625; mean36 = sum36/625;
mean37 = sum37/625; mean38 = sum38/625; mean39 = sum39/625; mean40 = sum40/625;




for a =126:150
for b = 1:25
if(tepiGambar(a,b) == putih) sum41 = sum41+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum42 = sum42+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum43 = sum43+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)== putih) sum44 = sum44+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)== putih) sum45 = sum45+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum46 = sum46+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum47 = sum47+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum48 = sum48+1;
end
end
end
mean41 = sum41/625; mean42 = sum42/625; mean43 = sum43/625; mean44 = sum44/625;
mean45 = sum45/625; mean46 = sum46/625; mean47 = sum47/625; mean48 = sum48/625;



for a =151:175
for b = 1:25
if(tepiGambar(a,b) == putih) sum49 = sum49+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum50 = sum50+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum51 = sum51+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)== putih) sum52 = sum52+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)== putih) sum53 = sum53+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum54 = sum54+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum55 = sum55+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum56 = sum56+1;
end
end
end
mean49 = sum49/625; mean50 = sum50/625; mean51 = sum51/625; mean52 = sum52/625;
mean53 = sum53/625; mean54 = sum54/625; mean55 = sum55/625; mean56 = sum56/625;


for a =176:200
for b = 1:25
if(tepiGambar(a,b) == putih) sum57 = sum57+1;
end
end
for c = 26:50
if(tepiGambar(a,c)== putih) sum58 = sum58+1;
end
end
for d = 51:75
if(tepiGambar(a,d) == putih) sum59 = sum59+1;
end
end
for e = 76 :100
if(tepiGambar(a,e)==putih) sum60 = sum60+1;
end
end
for f = 101 : 125
if(tepiGambar(a,f)==putih) sum61 = sum61+1;
end
end
for g = 126 : 150
if(tepiGambar(a,g) == putih) sum62 = sum62+1;
end
end
for h = 151 : 175
if(tepiGambar(a,h) == putih) sum63 = sum63+1;
end
end
for i = 176 : 200
if(tepiGambar(a,i) == putih) sum64 = sum64+1;
end
end
end


mean57 = sum57/625; mean58 = sum58/625; mean59 = sum59/625; mean60 = sum60/625;
mean61 = sum61/625; mean62 = sum62/625; mean63 = sum63/625; mean64 = sum64/625;

%HORIZONTAL
meanSatu = (mean1+mean2+mean3+mean4+mean5+mean6+mean7+mean8)/8;
meanDua = (mean9+mean10+mean11+mean12+mean13+mean14+mean15+mean16)/8;
meanTiga = (mean17+mean18+mean19+mean20+mean21+mean22+mean23+mean24)/8;
meanEmpat = (mean25+mean26+mean27+mean28+mean29+mean30+mean31+mean32)/8;
meanLima = (mean33+mean34+mean35+mean36+mean37+mean38+mean39+mean40)/8;
meanEnam = (mean41+mean42+mean43+mean44+mean45+mean46+mean47+mean48)/8;
meanTujuh = (mean49+mean50+mean51+mean52+mean53+mean54+mean55+mean56)/8;
meanDelapan = (mean57+mean58+mean59+mean60+mean61+mean62+mean63+mean64)/8;
%VERTICAL
meanSembilan = (mean1+mean9+mean17+mean25+mean33+mean41+mean49+mean57)/8;
meanSepuluh = (mean2+mean10+mean18+mean26+mean34+mean42+mean50+mean58)/8;
meanSebelas = (mean3+mean11+mean19+mean27+mean35+mean43+mean51+mean59)/8;
meanDuabelas = (mean4+mean12+mean20+mean28+mean36+mean44+mean52+mean60)/8;
meanTigabelas = (mean5+mean13+mean21+mean29+mean37+mean45+mean53+mean61)/8;
meanEmpatbelas = (mean6+mean14+mean22+mean30+mean38+mean46+mean54+mean62)/8;
meanLimabelas = (mean7+mean15+mean23+mean31+mean39+mean47+mean55+mean63)/8;
meanEnambelas = (mean8+mean16+mean24+mean32+mean40+mean48+mean49+mean64)/8;


feature =[feature,meanR,meanG,meanB,kadarR,kadarG,kadarB,meanRGB,meanSatu,meanDua,meanTiga,meanEmpat,meanLima,meanEnam,meanTujuh,meanDelapan,meanSembilan,meanSepuluh,meanSebelas,meanDuabelas,meanTigabelas,meanEmpatbelas,meanLimabelas,meanEnambelas,x];

% tulis ke dalam file feature
nama_file =[num2str(x) '_' num2str(y) '.txt'];
fid1=fopen(nama_file,'w');
fwrite(fid1, [num2str(feature)]);
fclose(fid1);
end
cd ..;
end

thats the code of programm to extractfeature and the value of image saved in in a text file (the ASCII values of 123). so,every images have one text file consist of 23 dimension or value. cluster image means clustering images based on simmilarity with kmeans clustering.the problem is how to cluster by that text file??how to process the value in text file to cluster in?




ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <76fe2892-a565-4d57-aa7c-96cd2a34e2c2(a)w12g2000yqj.googlegroups.com>...
> On Jul 31, 4:01 am, "agnes cawas" <o_nestblu...(a)yahoo.com> wrote:
> > i want to cluster images. I have extracted those images n saved in text file. so,if there 50 images, there will be 50 file text extraction..the problem is,I don't know how to process those file text to be clustered?
> > do you get what I mean?
> ---------------------------------------------------------------
> agnes:
> Sorry, but no, I don't understand. What does it mean to extract
> images into text files? Do you mean that you converted the image
> values into text strings? Like a gray level of 123 stored in binary
> uint8 format in your image would then be either "123" or "49" "50"
> "51" (the ASCII values of 123) in a text file? This makes no sense to
> me.
>
> And what does "cluster images" mean? Does that mean like you'd want
> to have, say, 6 clusters where you cluster on dominant color, like
> "reddish images," "greenish images," "bluish images," "brownish
> images," "whitish images," and "purplish images"??? And what would
> that have to do with writing these images out as text???