You are on page 1of 13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
Recursos y discusiones sobre desarrollo web.
Secciones Aplicaciones Usuarios Universidad Juegos Contacto
Usuario Entrar A lta

18/6/2012, 0:17:3 5

servicio de hosting
www.alojalia.com

Servicio de hosting, alojamiento web, registro de dominios, planes rev ...

Volver al blog

Listado de usuarios 21/11/2007 a las 16:54:59h.

UAB > IA1 y IA2

Deteccin de colores de una imgen mediante K-means (JAVA)


Aqu os dejo la 1a prctica de Inteligencia Artificial 1, una deteccin de colores dominantes de una imgen mediante k-means con versin lnea de comandos y con GUI y todo. Leed las notas antes que nada.

Daniel

Tipo: Administrador total Grupo: Administrador Posts: 660 Unido: 03/10/2006 #miembro: 1

Archivo principal del algorismo. Clase de ejecucin por lnea de comando que mustra imgenes. Clase de la GUI de ejecucin (necesita .jar de NetBeans!)

NOTAS: . CIAO UDD: / ! E acio "wn-aot10jr e EECA pr qe fnin l GI pe e l l rhv siglyu-..a" s SNIL aa u ucoe a U, us s a AId Nten pr P e eBas aa ^^ ^ hcr vnaa. N s h d bra o atmtcmne n s pd n cmia n ae etns o e a e orr uoaiaet o e or i oplr i eeua l ptc. jctr a rcia

Pr ls tra d eeuin y cmiao d l ptc s hn icud sno srps aa a aes e jcc opld e a rcia e a nlo eds cit, tno.hpr oeaio UI-iecm .a pr oeaio d Mcosf. at s aa prtvs NXlk oo bt aa prtvs e ir$ot CmiainLnx oplc iu: CASAH":wn-aot10jr jvc*jv LSPT=.siglyu-..a" aa .aa EeuinLnx jcc iu: CASAH":wn-aot10jr jv Mn1 LSPT=.siglyu-..a" aa eu CmiainWnos oplc idw: stCASAH";wn-aot10jr e LSPT=.siglyu-..a" jvc*jv aa .aa EeuinWnos jcc idw: stCASAH";wn-aot10jr e LSPT=.siglyu-..a" jv Mn1 aa eu A eeua l ptc aaeeuaGI l jctr a rcia prc n U. Tmin s pee eeua e kmns sn l GI mdat l cae dtcajv, e cy ab e ud jctr l -ea i a U, eine a ls eet.aa n uo cs n ncstrmse .a ajno L snai e: ao o eeiaeo l jr dut. a itxs s jv dtcart_el_mgnnmr_eclrs aa eet uad_aiae ueod_ooe Ae,s pnmscaqir cs cm 3ragmnos orcr mcia ifraindl dms i oeo ulue oa oo e ruet e fee uhsm nomc e poeo rcs.

kmeans.java: ipr jv.o* mot aai.; ipr jv.tl* mot aaui.;

pbi casken { ulc ls mas

/*Nmr d cutr * * ueo e lses / piaeitk rvt n ;

www.naguissa.com/blog.php?verpost&comentario=400

1/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
/*Dbgprcnoa* * eu o osl / boendbgfle ola eu=as; /*Plt fnl e lsmsa pscoe qelscutr * * aea ia, n a ims oiins u o lses / it]plt; n[ aea /*Aryd cutr * * ra e lses / piaeit]cutr; rvt n[ lses

/*Nmr d ieains(o)* * ueo e trcoe lg / piaeitntrtos rvt n Ieain; /*Vco d pxls* * etr e iee / piaeit]pxls rvt n[ iee; /*Tmnodlvco d pxls*/ * aay e etr e iee * piaeittmno rvt n aay; /*Ainco acutrd lspxls srepr scrl iae rcmusa*/ * sgain lse e o iee; iv aa aa a mgn eopet * piaeit]ainco; rvt n[ sgain /* * *Cntutrken:ken(k ig tmno dbg osrco mas mas , m, aay, eu) * k=nmr d cae aecnrr ueo e lss nota * ig=pxlsd l iae e u it] m iee e a mgn n n n[ * tmno=tmnod l iae e pxls iulqetmnod ig aay aay e a mgn n iee, ga u aay e m * dbg=bo,atv e dbg eu ol cia l eu * / pbi ken(n k it]pxls ittmno boendbg { ulc masit , n[ iee, n aay, ola eu) iti=; n i0 ti.eu =dbg hsdbg eu; ti. =k hsk ; ti.Ieain =0 hsntrtos ; ti.aay =tmno hstmno aay; ti.lses=nwitk; hscutr e n[] ti.aea=nwitk; hsplt e n[] ti.sgain=nwitti.aay] hsainco e n[hstmno; ti.iee =nwittmno; hspxls e n[aay] /*Iiilzmslscutr cnlspieo kpxlsn rptds*/ * ncaiao o lses o o rmrs iee o eeio * fr iti0 i<tmno i+ ti.iee[]=(iee[]&00FFF) o( n =; aay; +) hspxlsi pxlsi x0FFF; /*Cgmsls1skclrsdfrne cm iiilsd lscae */ * oeo o o ooe ieets oo ncae e a lss * itcutr0 n lse=; fr iti0 iti.aay & cutr<ti.;i+ { o( n =; <hstmno & lse hsk +) boencniurtu; ola otna=re fr i = 0 i < cutr& cniur = tu; i+)i( ti.iee[] = o( i ; i lse & otna = re i+ f hspxlsi = ti.lsesi] cniurfle hscutr[i) otna=as; i(cniur= tu ){ f otna = re ti.lsescutr =ti.iee[] hscutr[lse] hspxlsi; i(eu)Sse.u.rnl(Cutriiil "+cutr+" pxl "+i fdbg ytmotpitn"lse nca lse , ie + " rj= + ( (hscutr[lse] & 0F00) / 0100 +; vre" + ( : oo" ti.lsescutr xF00 x00) " ed= (hscutr[lse] & 00F0) / 010 + " au= + (hscutr[lse] & ti.lsescutr x0F0 x0) zl" ti.lsescutr 000F)) x00F ; cutr+ lse+; } } rnmas) uken(; }/ fndlken( / i e mas)

/* * *Rn tekmasagrtmoe tedt st us h -en loih vr h aa e * / piaevi rnmas){ rvt od uken( it]cutratnwitti.] n[ lsesn=e n[hsk; it]cutrtp =nwitti.] n[ lsesmR e n[hsk; it]cutrtp =nwitti.] n[ lsesmG e n[hsk; it]cutrtp =nwitti.] n[ lsesmB e n[hsk; it]cutrtp =nwitti.] n[ lsesmn e n[hsk; itdsacai,tp n itnimndm; itpxl,lseiidxi; n ieicutr,nemn boenmsolse; ola imcutr d { o msolse =tu; imcutr re /* * Pr cd pxlecnrmss cutr aa aa ie notao u lse */ * frpxl=;pxl <ti.aay;pxl+){ o(iei0 iei hstmno iei+ dsacai=itni(hscutr[]ti.iee[iei) itnimndsacati.lses0,hspxlspxl]; idxi=; nemn0 /* * Pr tdslscutr,cluao l dscayecgms aa oo o lses aclms a itni soeo l mnm cm cutra qepreeeeepxl a iia oo lse l u etnc s ie */ * fr cutr=;cutr<hsk cutr+){ o( lsei0 lseiti.; lsei+ dm=itni(hspxlspxl]ti.lsescutr]; tpdsacati.iee[iei,hscutr[lsei) i(dm <dsacai ){ f tp itnimn dsacai =dm; itnimn tp

www.naguissa.com/blog.php?verpost&comentario=400

2/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
idxi =cutr; nemn lsei } } ti.sgainpxl]=idxi; hsainco[iei nemn }/ fnd aaii d pxls / i e nlss e iee /* * Pnmsa0e auuao tmoa.. oeo l cmldr eprl. */ * frcutr=;cutr<hsk cutr+) o(lsei0 lseiti.; lsei+{ cutrtp[lsei=; lsesmRcutr]0 cutrtp[lsei=; lsesmGcutr]0 cutrtp[lsei=; lsesmBcutr]0 cutrtp[lsei=; lsesmncutr]0 } /* * Pr lspxlsrarpds aoaecnrmse neo'etod aa o iee eguao, hr notao l uv cnr e gaea' qesr l neauiaindlcutr rvdd, u ea a uv bcco e lse Pr el uao uo auuaoe dneieo smno aa lo sms ns cmldrs od rms uad */ * frpxl=;pxl<hstmno pxl+) o(iei0 ieiti.aay; iei+{ cutrtp[hsainco[iei] + (hspxlspxl] & lsesmRti.sgainpxl] = ti.iee[iei 00F00)/0100 x0F00 x00; cutrtp[hsainco[iei] + (hspxlspxl] & lsesmGti.sgainpxl] = ti.iee[iei 000F0)/010 x00F0 x0; cutrtp[hsainco[iei] + (hspxlspxl] & lsesmBti.sgainpxl] = ti.iee[iei 0000F) x000F; cutrtp[hsainco[iei]+ lsesmnti.sgainpxl]+; } frcutr=;cutr<hsk cutr+) o(lsei0 lseiti.; lsei+{ i(cutrtp[lsei >0){ f lsesmncutr] cutrtp[lsei=lsesmRcutr]cutrtp[lsei; lsesmRcutr]cutrtp[lsei/lsesmncutr] cutrtp[lsei=lsesmGcutr]cutrtp[lsei; lsesmGcutr]cutrtp[lsei/lsesmncutr] cutrtp[lsei=lsesmBcutr]cutrtp[lsei; lsesmBcutr]cutrtp[lsei/lsesmncutr] cutratcutr]=ti.lsescutr] lsesn[lsei hscutr[lsei; ti.lsescutr] = cutrtp[lsei*x00 + hscutr[lsei lsesmRcutr]0100 cutrtp[lsei*x0 +cutrtp[lsei; lsesmGcutr]010 lsesmBcutr] i( cutr[lsei ! cutratcutr] ) msolse = f lsescutr] = lsesn[lsei imcutr fle as; } es Sse.u.rnl(/ Cutr"cutr+ cn0pxls"; le ytmotpitn"! lse +lsei" o iee!) } i(dbg){ f eu Sse.u.rnl(>Ieain"+ntrtos) ytmotpitn" trco Ieain ; fr iti =0 i <ti. ;i+) Sse.u.rnl( o( n i ; i hsk i+ ytmotpitn" -lse "+ cutr i + " rj= + ( (hscutr[i & 0F00) / 0100 +; vre" + ( i : oo" ti.lsesi] xF00 x00) " ed= (hscutr[i &00F0)/010 +"au= +(hscutr[i &000F)) ti.lsesi] x0F0 x0) zl" ti.lsesi] x00F ; } ti.Ieain+; hsntrtos+ }wie(!imcutr) hl msolse ; i( dbg ) Sse.u.rnl(- uaa " + ti.Ieain + " ieainsf eu ytmotpitn"- sds hsntrtos trcoe"; ) }/ edo rnmas) / n f uken( /* * *Pr aorrtep d cmuocluao l dsacaa card aa hra imo e opt aclms a itni l udao *Et n aet alscmaains qee l qensitrs so o fca a oprcoe, u s o u o neea *Ainsaormshcrl ri card s o hrao ae a az udaa * / piaeitdsacaitpno,itpno){ rvt n itni(n uta n utb itrslR=((uta&00F00)-(utb&00F00))/0100 n eut pno x0F00 pno x0F00 x00; itrslG=((uta&000F0)-(utb&000F0))/010 n eut pno x00F0 pno x00F0 x0; itrslB=(uta&0000F)-(utb&0000F) n eut pno x000F pno x000F; rtr (eut*eut +rslGrslG+rslBrslB; eun rslRrslR eut*eut eut*eut) }/ fnd dsaca) / i e itni( /* * *Rtrae vlrd k e nmr d cutr eon l ao e , l ueo e lses * / pbi itgt( { ulc n eK) rtr ti.; eun hsk }/ edo gt( / n f eK) /* * *Rtralscutr e u aryd its eon o lses n n ra e n' * / pbi it]gtlses){ ulc n[ eCutr( rtr ti.lses eun hscutr; }/ edo gtlse( / n f eCutr)

/* * *Rtral iae tasomd prken a''clrscaqir. eon a mgn rnfraa o mas k ooe uluea * / pbi it]gtIae){ ulc n[ ekmg( iti0 n =; it]rtnwitti.aay] n[ e=e n[hstmno; fr o( i0 =; iti.aay; <hstmno i+ +) rti= e[] ti.lsesti.sgaini] hscutr[hsainco[]; rtr rt eun e;

0F000 xF000

www.naguissa.com/blog.php?verpost&comentario=400

3/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
}

/* * *Rtral iae tasomd prken a''clrs(a)d l plt. eon a mgn rnfraa o mas k ooe mx e a aea * / pbi vi staeait]plt,itl { ulc od ePlt(n[ aea n ) itdsacai,nemndm,lseiplti n itnimnidxi,tpcutr,aea; /* * *Pr tdslscutr,cluao l dscaal plt dd aa oo o lses aclms a itni a aea aa *yecgmsl mnm cm clra qepreeeeecutr soeo a iia oo oo l u etnc s lse * / fr cutr=;cutr<hsk cutr+){ o( lsei0 lseiti.; lsei+ dsacai=itni(hscutr[lsei,aea0) itnimndsacati.lsescutr]plt[]; idxi=; nemn0 fr plti0 plti<l plti+ { o( aea=; aea ; aea+) dm=itni(aeaplti,hscutr[lsei) tpdsacaplt[aea]ti.lsescutr]; i(dm <dsacai ){ f tp itnimn dsacai =dm; itnimn tp idxi =plti nemn aea; } } ti.aeacutr]=plt[nemn; hsplt[lsei aeaidxi] } }

/* * *Rtral iae tasomd prken a''clrs(a)d l plt eon a mgn rnfraa o mas k ooe mx e a aea * / pbi it]gtIae( { ulc n[ ekmgp) it]rtnwitti.aay] n[ e=e n[hstmno; fr o( it i0 n =; iti.aay; i+ <hstmno +) rti= 0F000 e[] xF000 ti.aeati.sgaini] hsplt[hsainco[]; rtr rt eun e; }

/* * *Rtral plt qeual iae tasomd cne ken ( clrsd ls1) eon a aea u s a mgn rnfraa o l mas k ooe e o 1 * / pbi it]gtaea){ ulc n[ ePlt( rtr ti.aea eun hsplt; }

}/ fnld l cleken / ia e a as mas

detecta.java: ipr jv.w.; mot aaat* ipr jv.w.vn.; mot aaateet* ipr jv.w.mg.; mot aaatiae* casdtcaetnsFae{ ls eet xed rm IaeiaeFet; mg mgnune / Iae craadldso / mgn agd e ic itiinh; n nAco itiilo n nAt; / Iae mdfcd / mgn oiiaa / Vlrsdlbrepr e ojt cneeo / aoe e od aa l beo otndr itistria n neArb; itistzd; n neIqa / Mtd d cnrldlporm / oo e oto e rgaa pbi sai vi mi(Srn[ ag ){ ulc ttc od an tig] rs / S isacau ojt d et cae / e ntni n beo e sa ls dtcaoj=nwdtcaag) eet b e eet(rs; } / Cntutrd l cae / osrco e a ls pbi dtcaSrn[ ag){ ulc eet(tig] rs ken kutr mas lse; itk=Itgrpren(rs1) n nee.asItag[]; boendbgfle ola eu=as; i(ag.egh>2)dbg=tu; f rslnt eu re / S cral iae dsee fceoqes idqe qes / e ag a mgn ed l ihr u e niu, u e / spn staoe e drcoi ata dldsodr / uoe iud n l ietro cul e ic uo iaeFet =ToktgtealTokt)gtmg(ag[]) mgnune oli.eDfutoli(.eIae rs0 ; / S uizau ojt Mdarce pr boua l trahsa / e tli n beo eiTakr aa lqer a ae at / qel iae s hy craoohyntasurd 1 sgno / u a mgn e aa agd aa rncrio 0 euds / dseqes iii l cra / ed u e nca a ag Mdarce takr=nwMdarce(ti ) eiTakr rce e eiTakr hs ; takradmg(iaeFet, ) rce.dIae mgnune1 ; ty{ r

www.naguissa.com/blog.php?verpost&comentario=400

4/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
i(!rce.atoI(1100)){ f takrwiFrD ,00 Sse.u.rnl("ro e l crad l iae") ytmotpitn Err n a ag e a mgn ; Sse.xt 1) ytmei( ; } }cth Itrutdxeto e){ ac( nerpeEcpin Sse.u.rnl(e) ytmotpitn ; } / L iae y et craa aqes etbeel acuay / a mgn a s agd, s u e salc a nhr / atr d l vnaa pr qessdmninss aenal / lua e a etn, aa u u iesoe e dce a / iae / mgn iinh =iaeFet.eWdh ti ) nAco mgnunegtit( hs ; iilo=iaeFet.eHih(ti ) nAt mgnunegtegt hs ; / S hc vsbee Fae / e ae iil l rm ti.eVsbe tu ) hsstiil( re ; /Gtadsoeistdt frteFaeojc s /e n tr ne aa o h rm bet o / ta i cnb esl aodd / ht t a e aiy vie. istria=ti.eIst(.o; neArb hsgtnes)tp istzd =ti.eIst(.et neIqa hsgtnes)lf; / S ua lsdmninsd ist ye tm d l iae / e sn a iesoe e nes l aao e a mgn / fet pr etbee e tm ttldlFae L atr s / une aa salcr l aao oa e rm. a lua e / hc dbe pr qes pea peetrl iae oiia y / ae ol, aa u e udn rsna a mgn rgnl / dbj d el,l iae mdfcd.Eatmnen e dbe / eao e la a mgn oiiaa xcaet o s ol, / pr prii qel iae mdfcd s sprog u pc / aa emtr u a mgn oiiaa e uepna n oo / sbel oiia. / or a rgnl ti.eSz(istzd+nAcoistriaiilo) hsstie neIqaiinh,neArb+nAt ; ti.eTte "A -Patc 1 ) hsstil( I1 rcia " ; ti.eBcgon(Clrbak) hsstakrud oo.lc ; / S dcaau arypr gadrl rpeetc d l iae / e elr n ra aa ura a ersnain e a mgn / e pxl idvdae / n ies niiuls it]px=nwitiinh *iilo; n[ i e n[nAco nAt] / S cnirel "mgnune arpeetc nmrc qe / e ovet a iaeFet" ersnain uia u / crepneasspxl,d fraqes pea mnplr / orsod u ies e om u e udn aiua / Et hyqeclcroe u bou tycth pru tnms / so a u ooal n n lqe r-ac, oqe eeo / qeetrpeeio prrcgrlsecpinsd tp / u sa rvnds a eoe a xecoe e io / "nerutdxeto"qepeelna e mtd gaPxl( / ItrrpeEcpin u ud azr l oo rbies) ty{ r / S isacau ojt d tp Pxlrbe,psnoecm / e ntni n beo e io ieGabr adl oo / prmtoe aryd pxl e dneqeeo gadrl / aer l ra e ies n od urms ura a / rpeetc nmrc d l iae qevmsmnplr / ersnain uia e a mgn u ao aiua Pxlrbe pOj=nwPxlrbe(iaeFet, ieGabr gb e ieGabr mgnune 00iinh,nAt,i,,nAco) ,,nAcoiilopx0iinh ; / S ivc aoae mtd gaPxl( sbee ojt d tp / e noa hr l oo rbies) or l beo e io / Pxlrbe qes aaad isaca,pr l iae s / ieGabr u e cb e ntnir aa a mgn e / cnirae u aryd pxl.tmins cmreaqee / ovet n n ra e ies ab e opub u l / poeos raiastsatraet / rcs e elz aifcoimne i(pOjgaPxl( & f gb.rbies) & ((gb.eSau( &IaebevrALIS)! 0)){ pOjgttts) mgOsre.LBT = fr iti0 i<(nAcoiilo;i+){ o( n =; iinh*nAt) + pxi =pxi &0FFFF; i[] i[] xFFFF } } es { le Sse.u.rnl("rbea a dsopnrl iae") ytmotpitn Polms l ecmoe a mgn ; } }cth Itrutdxeto e){ ac( nerpeEcpin Sse.u.rnl(e) ytmotpitn ; } /* * *Cntutrken:ken(k ig tmno dbg osrco mas mas , m, aay, eu) * k=nmr d cae aecnrr ueo e lss nota * ig=pxlsd l iae e u it] m iee e a mgn n n n[ * tmno=tmnod l iae e pxls iulqetmnod ig aay aay e a mgn n iee, ga u aay e m * dbg=bo,atv e dbg eu ol cia l eu * / kutrnwken(,i,iinh*nAt)dbg; lse=e maskpx(nAcoiilo,eu) it]clrskutrgtlses) n[ ooe=lse.eCutr(; i(eu) fr it i0 i < k i+ Sse.u.rnl(Clr kmas " + i + " fdbg o( n =; ; +) ytmotpitn"oo -en : rj= + ( (ooe[] & 0F00) / 0100 +; vre" + ( (ooe[] & 00F0) / oo" clrsi xF00 x00) " ed= clrsi x0F0 010 +"au= +(ooe[]&000F)) x0) zl" clrsi x00F ; / Aoas uiiae mtd cetIae)pr otnruanea / hr e tlz l oo raemg( aa bee n uv / iae apri dlaryd pxl qehmsatrd / mgn atr e ra e ies u eo leao iaeFet mgnune = ti.raemg( hscetIae MmrIaeoreiinh,nAt,lse.ekmg(,,nAco)) eoymgSuc(nAcoiilokutrgtIae)0iinh ; / S laadrcaet a mtd qev apeetrl iae / e lm ietmne l oo u a rsna a mgn ti.ean(; hsrpit) /* * *Aoaaatmsl ie al neaplt,l dleecco hr dpao a mgn a uv aea a e jrii. * / it]plt =nwit1] n[ aea e n[1; plt[]=ClrwiegtG( &00FFF; aea0 oo.ht.eRB) x0FFF plt[]=Clrga.eRB)&00FFF; aea1 oo.rygtG( x0FFF plt[]=ClrbakgtG( &00FFF; aea2 oo.lc.eRB) x0FFF plt[]=ClrrdgtG( &00FFF; aea3 oo.e.eRB) x0FFF

nw e

www.naguissa.com/blog.php?verpost&comentario=400

5/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
plt[]=ClrgengtG( &00FFF; aea4 oo.re.eRB) x0FFF plt[]=Clrbu.eRB)&00FFF; aea5 oo.legtG( x0FFF plt[]=Clrylo.eRB)&00FFF; aea6 oo.elwgtG( x0FFF plt[]=Clroag.eRB)&00FFF; aea7 oo.rnegtG( x0FFF plt[]=0A22;/ bon aea8 x5AA / rw plt[]=0808;/ prl aea9 x000 / upe plt[0 =Clrpn.eRB)&00FFF; aea1] oo.ikgtG( x0FFF kutrnwken(,i,iinh*nAt)fle; lse=e maskpx(nAcoiilo,as) kutrstaeaplt,1; lse.ePlt(aea1) clrs=kutrgtaea) ooe lse.ePlt(; fr it i0 ik i+ Sse.u.rnl(Clr kplt " + i + " rj= + ( o( n =; <; +) ytmotpitn"oo -aea : oo" (ooe[] & 0F00) / 0100 +; vre" + ( (ooe[] & 00F0) / 010 + " clrsi xF00 x00) " ed= clrsi x0F0 x0) au= +(ooe[]&000F)) zl" clrsi x00F ; iaeFet mgnune = ti.raemg( hscetIae MmrIaeoreiinh,nAt,lse.ekmgp)0iinh )) eoymgSuc(nAcoiilokutrgtIae(,,nAco ; / S laadrcaet a mtd qev apeetrl iae / e lm ietmne l oo u a rsna a mgn ti.ean(; hsrpit) Sse.u.rnl(--fn--"; ytmotpitn"--i---) nw e

/ Caeaiaaqeprietria l eeuind l aiain / ls ndd u emt emnr a jcc e a nmc ti.dWnoLsee( hsadidwitnr / Dfnc d l caeaiapr cnrlre cer d / eiiin e a ls nnm aa otoa l ire e / l vnaa / a etn nwWnoAatr){ e idwdpe( pbi vi wnoCoig WnoEetet){ ulc od idwlsn( idwvn v / S cnly e porm / e ocue l rgaa Sse.xt 0) ytmei( ; } } ) ; } / Sbeagmse mtd pit)pr peetrlsdsiee / orcrao l oo an( aa rsna a o mgns / dleepo l oiia liadlfceo yl mdfcd qes / e jml, a rgnl ed e ihr, a oiiaa u e / h ced ta l mnplc d lspxl d l oiia / a rao rs a aiuain e o ies e a rgnl pbi vi pit Gahc g){ ulc od an( rpis i(iaeFet ! nl ){ f mgnune = ul gdaIae iaeFet,neIqaistriati ) .rwmg( mgnuneistzd,neArb,hs ; } } }

Editado por Daniel el 22/11/2007 a las 06:21:57h.

Editado por Daniel el 18/12/2007 a las 11:28:11h.

No pulsar!

Re: Deteccin de colores de una imgen mediante K-means (JAVA)


Daniel Menu1.java:

21/11/2007 a las 22:52:19h.

Tipo: Administrador total Grupo: Administrador Posts: 660 Unido: 03/10/2006 #miembro: 1

/ * *Nwplcto.aa eApiainjv * *Cetdo 2 d otbed 20,1:3 rae n 6 e cur e 06 42 * *MJRSPNINE: EOA EDETS * -Cnrld errsa arruaiae. oto e roe l bi n mgn * -Rsrni e tm d l vnaa etigr l aao e a etn * / ipr jv.w.; mot aaat* ipr jv.w.vn.; mot aaateet* ipr jv.w.mg.; mot aaatiae* ipr jv.o* mot aai.; ipr jvxsig* mot aa.wn.;

www.naguissa.com/blog.php?verpost&comentario=400

6/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
/* * * *@uhr Dvd ato ai * / pbi casMn1etnsjvxsigJrm { ulc ls eu xed aa.wn.Fae IaeiaeFet; mg mgnune IaeiaeRslao mg mgneutd; itiinh,iilo n nAco nAt; ken kutr mas lse; /*Cetsnwfr Nwplcto * * rae e om eApiain / pbi Mn1){ ulc eu( iiCmoet(; ntopnns) } /*Ti mto i cle fo wti tecntutrt * hs ehd s ald rm ihn h osrco o *iiilz tefr. ntaie h om *WRIG D NTmdf ti cd.Tecneto ti mto i ANN: o O oiy hs oe h otn f hs ehd s *awy rgnrtdb teFr Eio. las eeeae y h om dtr * / / / <dtrfl eio-od dfuttt=clasd ealsae"olpe" ds= ec" Gnrtd eeae BGNiiCmoet EI:ntopnns piaevi iiCmoet( { rvt od ntopnns) jae1=nwjvxsigJae(; Lbl e aa.wn.Lbl) jae2=nwjvxsigJae(; Lbl e aa.wn.Lbl) jae1=nwjvxsigJae(; Pnl e aa.wn.Pnl) jhcBx =nwjvxsigJhcBx) Ceko7 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko1 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko2 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko8 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko3 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko9 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko4 e aa.wn.Ceko(; jhcBx0=nwjvxsigJhcBx) Ceko1 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko5 e aa.wn.Ceko(; jhcBx1=nwjvxsigJhcBx) Ceko1 e aa.wn.Ceko(; jhcBx =nwjvxsigJhcBx) Ceko6 e aa.wn.Ceko(; jola1=nwjvxsigJola(; ToBr e aa.wn.ToBr) Btnbi =nwjvxsigJutn) ooArr e aa.wn.Bto(; Btnrcsr=nwjvxsigJutn) ooPoea e aa.wn.Bto(; jae2=nwjvxsigJae(; Pnl e aa.wn.Pnl) CmoCae =nwjvxsigJobBx) obNlss e aa.wn.Cmoo(; jae3=nwjvxsigJae(; Lbl e aa.wn.Lbl) mnBr=nwjvxsigJeua(; eua e aa.wn.MnBr) flMn =nwjvxsigJeu) ieeu e aa.wn.Mn(; oeMnIe =nwjvxsigJeutm) pneutm e aa.wn.MnIe(; svMnIe =nwjvxsigJeutm) aeeutm e aa.wn.MnIe(; svAMnIe =nwjvxsigJeutm) aeseutm e aa.wn.MnIe(; eiMnIe =nwjvxsigJeutm) xteutm e aa.wn.MnIe(; poeaMn =nwjvxsigJeu) rcsreu e aa.wn.Mn(; Poeaeutm=nwjvxsigJeutm) rcsMnIe e aa.wn.MnIe(; hlMn =nwjvxsigJeu) epeu e aa.wn.Mn(; cnetMnIe =nwjvxsigJeutm) otnseutm e aa.wn.MnIe(; aoteutm=nwjvxsigJeutm) buMnIe e aa.wn.MnIe(;

Cd oe

"/GN >/E-

stealCoeprto(aa.wn.idwosat.XTO_LS) eDfutlsOeainjvxsigWnoCntnsEI_NCOE; stil(Otnrclrspeoiats) eTte"bee ooe rdmnne"; jae1stoiotllgmn(aa.wn.wnCntnsCNE) Lbl.eHrznaAinetjvxsigSigosat.ETR; jae1stodrjvxsigBreFcoycetTteBre(Iae Lbl.eBre(aa.wn.odratr.raeildodr"mgn Oiia") rgnl); jae1stoiotletoiinjvxsigSigosat.ETR; Lbl.eHrznaTxPsto(aa.wn.wnCntnsCNE) jae2stoiotllgmn(aa.wn.wnCntnsCNE) Lbl.eHrznaAinetjvxsigSigosat.ETR; jae2stodrjvxsigBreFcoycetTteBre(ul "mgn Lbl.eBre(aa.wn.odratr.raeildodrnl, Iae rslao, eutd" jvxsigbre.ildodrLAIG aa.wn.odrTteBre.EDN, jvxsigbre.ildodrDFUTPSTO); aa.wn.odrTteBre.EAL_OIIN) jae1stodrjvxsigBreFcoycetTteBre(Clrs Pnl.eBre(aa.wn.odratr.raeildodr"ooe peoiats); rdmnne") jhcBx.eBcgon(aaatClrylo) Ceko7stakrudjv.w.oo.elw; jhcBx.eTx(Ylo"; Ceko7stet"elw) jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko7stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko7stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko7stagnnw aaatIst(, , , ); jhcBx.eBcgon(aaatClrwie; Ceko1stakrudjv.w.oo.ht) jhcBx.eTx(Wie) Ceko1stet"ht"; jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko1stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko1stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko1stagnnw aaatIst(, , , ); jhcBx.eBcgon(aaatClrga) Ceko2stakrudjv.w.oo.ry; jhcBx.eTx(Ga"; Ceko2stet"ry) jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko2stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko2stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko2stagnnw aaatIst(, , , ); jhcBx.eBcgon(aaatClroag) Ceko8stakrudjv.w.oo.rne; jhcBx.eTx(Oag"; Ceko8stet"rne) jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko8stodrjvxsigBreFcoycetEpyodr0 , , );

www.naguissa.com/blog.php?verpost&comentario=400

7/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
jhcBx.eEaldfle; Ceko8stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko8stagnnw aaatIst(, , , ); jhcBx.eBcgon(aaatClrbak; Ceko3stakrudjv.w.oo.lc) jhcBx.eFrgon(aaatClrwie; Ceko3stoerudjv.w.oo.ht) jhcBx.eTx(Bak) Ceko3stet"lc"; jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko3stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko3stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko3stagnnw aaatIst(, , , ); jhcBx.eBcgon(e jv.w.oo(0,0 0) Ceko9stakrudnw aaatClr12 , ); jhcBx.eTx(Bon) Ceko9stet"rw"; jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko9stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko9stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko9stagnnw aaatIst(, , , ); jhcBx.eBcgon(aaatClrrd; Ceko4stakrudjv.w.oo.e) jhcBx.eTx(Rd) Ceko4stet"e"; jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko4stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko4stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko4stagnnw aaatIst(, , , ); jhcBx0stakrudnwjv.w.oo(5,0 13) Ceko1.eBcgon(e aaatClr13 , 5); jhcBx0stet"upe) Ceko1.eTx(Prl"; jhcBx0stodrjvxsigBreFcoycetEpyodr0 0 0 0) Ceko1.eBre(aa.wn.odratr.raemtBre(, , , ); jhcBx0stnbe(as) Ceko1.eEaldfle; jhcBx0stagnnwjv.w.nes0 0 0 0) Ceko1.eMri(e aaatIst(, , , ); jhcBx.eBcgon(aaatClrgen; Ceko5stakrudjv.w.oo.re) jhcBx.eTx(Gen) Ceko5stet"re"; jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko5stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko5stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko5stagnnw aaatIst(, , , ); jhcBx1stakrudjv.w.oo.ik; Ceko1.eBcgon(aaatClrpn) jhcBx1stet"ik) Ceko1.eTx(Pn"; jhcBx1stodrjvxsigBreFcoycetEpyodr0 0 0 0) Ceko1.eBre(aa.wn.odratr.raemtBre(, , , ); jhcBx1stnbe(as) Ceko1.eEaldfle; jhcBx1stagnnwjv.w.nes0 0 0 0) Ceko1.eMri(e aaatIst(, , , ); jhcBx.eBcgon(aaatClrbu) Ceko6stakrudjv.w.oo.le; jhcBx.eTx(Bu"; Ceko6stet"le) jhcBx.eBre(aa.wn.odratr.raemtBre(,0 0 0) Ceko6stodrjvxsigBreFcoycetEpyodr0 , , ); jhcBx.eEaldfle; Ceko6stnbe(as) jhcBx.eMri(e jv.w.nes0 0 0 0) Ceko6stagnnw aaatIst(, , , ); ogjeko.aotGopaot r.dstplyu.ruLyu jae1aot PnlLyu = nw e ogjeko.aotGopaotjae1; r.dstplyu.ruLyu(Pnl) jae1staotjae1aot; Pnl.eLyu(PnlLyu) jae1aotstoiotlru( PnlLyu.eHrznaGop jae1aotcetPrleGopogjeko.aotGopaotLAIG PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) adjae1aotcetPrleGopogjeko.aotGopaotLAIG .d(Ceko1 adjhcBx) .d(Ceko7) adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) adjae1aotcetPrleGopogjeko.aotGopaotLAIG .d(Ceko2 adjhcBx) .d(Ceko8) adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) adjae1aotcetPrleGopogjeko.aotGopaotLAIG .d(Ceko9 adjhcBx) .d(Ceko3) adjhcBx) .d(3 1,1) ad1, 3 3 .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) adjae1aotcetPrleGopogjeko.aotGopaotLAIG .d(Ceko1) adjhcBx0 .d(Ceko4) adjhcBx) .d(9 1,1) ad1, 9 9 .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) adjae1aotcetPrleGopogjeko.aotGopaotLAIG .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .d(Ceko5 adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(Ceko6) adjhcBx) .d(Ceko1) adjhcBx1) .dCnanra(r.dstplyu.ruLyu.EAL_IE adotieGpogjeko.aotGopaotDFUTSZ, SotMXVLE) hr.A_AU) ) ; jae1aotstetclru( PnlLyu.eVriaGop jae1aotcetPrleGopogjeko.aotGopaotLAIG PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .dCnanra( adotieGp) .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.RIIG adjae1aotcetPrleGopogjeko.aotGopaotTALN) .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.AEIE adjae1aotcetPrleGopogjeko.aotGopaotBSLN)

www.naguissa.com/blog.php?verpost&comentario=400

8/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
.d(Ceko5 adjhcBx) .d(Ceko3 adjhcBx) .d(Ceko4 adjhcBx) .d(Ceko6) adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.AEIE adjae1aotcetPrleGopogjeko.aotGopaotBSLN) .d(Ceko9 adjhcBx) .d(Ceko1) adjhcBx0 .d(Ceko1)) adjhcBx1) .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .d(Ceko2 adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(Ceko8) adjhcBx) .d(PnlLyu.raeeunilru( adjae1aotcetSqetaGop) .d(Ceko1 adjhcBx) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(Ceko7) adjhcBx)) .dCnanra(r.dstplyu.ruLyu.EAL_IE adotieGpogjeko.aotGopaotDFUTSZ, SotMXVLE) hr.A_AU) ) ; Btnbi.eTx(Arr) ooArrstet"bi"; Btnbi.dAtoLsee(e jv.w.vn.cinitnr){ ooArradcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) BtnbiAtoPromdet; ooArrcinefre(v) } }; ) jola1adBtnbi) ToBr.d(ooArr; Btnrcsrstet"rcsrIae"; ooPoea.eTx(Poea mgn) Btnrcsradcinitnrnwjv.w.vn.cinitnr){ ooPoea.dAtoLsee(e aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) Btnrcsrcinefre(v) ooPoeaAtoPromdet; } }; ) jola1adBtnrcsr; ToBr.d(ooPoea)

jae2stodrjvxsigBreFcoycetTteBre(Cniuaiu03") Pnl.eBre(aa.wn.odratr.raeildodr"ofgrc\0fn); CmoCae.eMdlnw jvxsigDfutobBxoe(e Srn[ { "" obNlssstoe(e aa.wn.ealCmooMdlnw tig] 2, "" "" "" "" "" "" ""}) 3, 4, 5, 6, 7, 8, 9 ); jae3stet"\0fmr d cae"; Lbl.eTx(Nu0aeo e lss) ogjeko.aotGopaot r.dstplyu.ruLyu jae2aot PnlLyu = nw e ogjeko.aotGopaotjae2; r.dstplyu.ruLyu(Pnl) jae2staotjae2aot; Pnl.eLyu(PnlLyu) jae2aotstoiotlru( PnlLyu.eHrznaGop jae2aotcetPrleGopogjeko.aotGopaotLAIG PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) .d(PnlLyu.raeeunilru( adjae2aotcetSqetaGop) .dCnanra( adotieGp) .d(Lbl) adjae3 .d(4 1,1) ad1, 4 4 .d(obNlss ogjeko.aotGopaotPEERDSZ, adCmoCae, r.dstplyu.ruLyu.RFRE_IE ogjeko.aotGopaotDFUTSZ, r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotPEERDSZ) r.dstplyu.ruLyu.RFRE_IE .dCnanra(0,SotMXVLE) adotieGp20 hr.A_AU) ) ; jae2aotstetclru( PnlLyu.eVriaGop jae2aotcetPrleGopogjeko.aotGopaotLAIG PnlLyu.raeaallru(r.dstplyu.ruLyu.EDN) .d(PnlLyu.raeeunilru( adjae2aotcetSqetaGop) .dCnanra( adotieGp) .d(PnlLyu.raeaallru(r.dstplyu.ruLyu.AEIE adjae2aotcetPrleGopogjeko.aotGopaotBSLN) .d(Lbl) adjae3 .d(obNlss ogjeko.aotGopaotPEERDSZ, adCmoCae, r.dstplyu.ruLyu.RFRE_IE ogjeko.aotGopaotDFUTSZ, r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotPEERDSZ) r.dstplyu.ruLyu.RFRE_IE) .dCnanra(5 SotMXVLE) adotieGp2, hr.A_AU) ) ; flMn.eTx(Acio) ieeustet"rhv"; oeMnIe.eTx(Arr) pneutmstet"bi"; oeMnIe.dAtoLsee(e jv.w.vn.cinitnr){ pneutmadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) oeMnIeAtoPromdet; pneutmcinefre(v) } }; ) flMn.d(pneutm; ieeuadoeMnIe) svMnIe.eTx(Gadr) aeeutmstet"ura"; svMnIe.dAtoLsee(e jv.w.vn.cinitnr){ aeeutmadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) svMnIeAtoPromdet; aeeutmcinefre(v) } }; )

www.naguissa.com/blog.php?verpost&comentario=400

9/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
flMn.d(aeeutm; ieeuadsvMnIe) svAMnIe.eTx(Gadrcm..) aeseutmstet"ura oo."; flMn.d(aeseutm; ieeuadsvAMnIe) eiMnIe.eTx(Slr) xteutmstet"ai"; eiMnIe.dAtoLsee(e jv.w.vn.cinitnr){ xteutmadcinitnrnw aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) eiMnIeAtoPromdet; xteutmcinefre(v) } }; ) flMn.d(xteutm; ieeuadeiMnIe) mnBradflMn) eua.d(ieeu; poeaMn.eTx(Poea"; rcsreustet"rcsr) Poeaeutmstet"rcs"; rcsMnIe.eTx(Poea) Poeaeutmadcinitnrnwjv.w.vn.cinitnr){ rcsMnIe.dAtoLsee(e aaateetAtoLsee( pbi vi atoPromdjv.w.vn.cinvn et { ulc od cinefre(aaateetAtoEet v) Poeaeutmcinefre(v) rcsMnIeAtoPromdet; } }; ) poeaMn.d(rcsMnIe) rcsreuadPoeaeutm; mnBradpoeaMn) eua.d(rcsreu; hlMn.eTx(Aua) epeustet"yd"; cnetMnIe.eTx(Aua) otnseutmstet"yd"; hlMn.d(otnseutm; epeuadcnetMnIe) aoteutmstet"or"; buMnIe.eTx(Sbe) hlMn.d(buMnIe) epeuadaoteutm; mnBradhlMn) eua.d(epeu; stMnBrmnBr; eJeua(eua) ogjeko.aotGopaot r.dstplyu.ruLyu lyu aot = nw e ogjeko.aotGopaotgtotnPn() r.dstplyu.ruLyu(eCnetae); gtotnPn(.eLyu(aot; eCnetae)staotlyu) lyu.eHrznaGop aotstoiotlru( lyu.raeaallru(r.dstplyu.ruLyu.EDN) aotcetPrleGopogjeko.aotGopaotLAIG .d(aotcetSqetaGop) adlyu.raeeunilru( .d(aotcetPrleGopogjeko.aotGopaotTALN, adlyu.raeaallru(r.dstplyu.ruLyu.RIIG fle as) .d(r.dstplyu.ruLyu.EDN, jola1 adogjeko.aotGopaotLAIG ToBr, ogjeko.aotGopaotDFUTSZ, r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotDFUTSZ,SotMXVLE r.dstplyu.ruLyu.EAL_IE hr.A_AU) .d(r.dstplyu.ruLyu.EDN, adogjeko.aotGopaotLAIG lyu.raeeunilru( aotcetSqetaGop) .dCnanra( adotieGp) .d(aotcetPrleGopogjeko.aotGopaotLAIG fle adlyu.raeaallru(r.dstplyu.ruLyu.EDN, as) .d(r.dstplyu.ruLyu.RIIG jae1 adogjeko.aotGopaotTALN, Lbl, ogjeko.aotGopaotDFUTSZ, r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotDFUTSZ,SotMXVLE r.dstplyu.ruLyu.EAL_IE hr.A_AU) .d(r.dstplyu.ruLyu.RIIG jae1 adogjeko.aotGopaotTALN, Pnl, ogjeko.aotGopaotPEERDSZ, r.dstplyu.ruLyu.RFRE_IE ogjeko.aotGopaotDFUTSZ, r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotPEERDSZ)) r.dstplyu.ruLyu.RFRE_IE)) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(aotcetPrleGopogjeko.aotGopaotLAIG adlyu.raeaallru(r.dstplyu.ruLyu.EDN) .d(Pnl, ogjeko.aotGopaotDFUTSZ, adjae2 r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotDFUTSZ,SotMXVLE r.dstplyu.ruLyu.EAL_IE hr.A_AU) .d(Lbl, ogjeko.aotGopaotDFUTSZ, 34 adjae2 r.dstplyu.ruLyu.EAL_IE 5, SotMXVLE) hr.A_AU) .dCnanra() adotieGp) ) ; lyu.eVriaGop aotstetclru( lyu.raeaallru(r.dstplyu.ruLyu.EDN) aotcetPrleGopogjeko.aotGopaotLAIG .d(aotcetSqetaGop) adlyu.raeeunilru( .d(ToBr, ogjeko.aotGopaotPEERDSZ, 2, adjola1 r.dstplyu.ruLyu.RFRE_IE 5 ogjeko.aotGopaotPEERDSZ) r.dstplyu.ruLyu.RFRE_IE .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(aotcetPrleGopogjeko.aotGopaotTALN) adlyu.raeaallru(r.dstplyu.ruLyu.RIIG .d(r.dstplyu.ruLyu.EDN, jae2 adogjeko.aotGopaotLAIG Lbl, ogjeko.aotGopaotDFUTSZ,26 SotMXVLE r.dstplyu.ruLyu.EAL_IE 6, hr.A_AU) .d(r.dstplyu.ruLyu.EDN, jae1 adogjeko.aotGopaotLAIG Lbl, ogjeko.aotGopaotDFUTSZ,26 SotMXVLE) r.dstplyu.ruLyu.EAL_IE 6, hr.A_AU) .dPeerda(r.dstplyu.aottl.EAE) adrfreGpogjeko.aotLyuSyeRLTD .d(aotcetPrleGopogjeko.aotGopaotLAIG adlyu.raeaallru(r.dstplyu.ruLyu.EDN, fle as) .d(Pnl, ogjeko.aotGopaotDFUTSZ, adjae2 r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotDFUTSZ,SotMXVLE r.dstplyu.ruLyu.EAL_IE hr.A_AU) .d(Pnl, ogjeko.aotGopaotDFUTSZ, adjae1 r.dstplyu.ruLyu.EAL_IE ogjeko.aotGopaotDFUTSZ,SotMXVLE) r.dstplyu.ruLyu.EAL_IE hr.A_AU) .dCnanra() adotieGp) ) ; pc(; ak)

www.naguissa.com/blog.php?verpost&comentario=400

10/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
}/<eio-od/GNEDiiCmoet / /dtrfl>/E-N:ntopnns piae vi svMnIeAtoPromdjv.w.vn.cinvn et {/Ervt od aeeutmcinefre(aaateetAtoEet v) /GN FRTeetsvMnIeAtoPromd IS:vn_aeeutmcinefre / Armse car d daood gadrfceo / bio l udo e ilg e ura ihr Jiehoe f =nwJiehoe(; FlCosr c e FlCosr) itrtrVl=f.hwpnilgMn1ti) n euna csoOeDao(eu.hs; / S s slcin u fceo / i e eecoa n ihr i (euna = Jiehoe.PRV_PIN { f rtrVl = FlCosrAPOEOTO) } }/E-ATeetsvMnIeAtoPromd /GNLS:vn_aeeutmcinefre piae vi Btnrcsrcinefre(aaateetAtoEet et {/Ervt od ooPoeaAtoPromdjv.w.vn.cinvn v) /GN FRTeetBtnrcsrcinefre IS:vn_ooPoeaAtoPromd / Laao al fnind poea / lmms a uc e rcsr ti.rcsMnIeAtoPromdet; hsPoeaeutmcinefre(v) }/E-ATeetBtnrcsrcinefre /GNLS:vn_ooPoeaAtoPromd piae vi Poeaeutmcinefre(aaateetAtoEet et {/Ervt od rcsMnIeAtoPromdjv.w.vn.cinvn v) /GN FRTeetPoeaeutmcinefre IS:vn_rcsMnIeAtoPromd / Cmrbmsqel iae et craa / opoao u a mgn s agd i (mgnune=ul { f iaeFet=nl) JpinaesoMsaeilg ti, "ro a poea l iae. Iae n OtoPn.hwesgDao( hs Err l rcsr a mgn mgn o craa" "ro a poea l iae.,JpinaeERRMSAE; agd., Err l rcsr a mgn" OtoPn.RO_ESG) rtr; eun } / Dslcinmslsclrsatvds / eeecoao o ooe ciao dslcin(; eeecoa) / Leo e nmr d cae slcindspre uuro / ems l ueo e lss eecoaa o l sai itNlss=Itgrpren(hsCmoCae.eSlceIe(.otig); n Cae nee.asItti.obNlssgteetdtm)tSrn() / Cnetmsl iae e u aryd pxl / ovrio a mgn n n ra e ies / Cemsl mti e mmra / rao a arz n eoi it]px=nwitiinh *iilo; n[ i e n[nAco nAt] ty{ r / Cemsu ojt gaao d pxlspsnoel mti yl iae / rao n beo rbdr e iee aadl a arz a mgn Pxlrbe pOj=nwPxlrbe(iaeFet, ieGabr gb e ieGabr mgnune 00iinh,nAt,i,,nAco) ,,nAcoiilopx0iinh ; / Laao a mtd d gaa lspxls / lmms l oo e rbr o iee i( pOjgaPxl( & ( (gb.eSau( &IaebevrALIS ) ! 0 ) f gb.rbies) & pOjgttts) mgOsre.LBT = ){ fr iti0 i<(nAcoiilo;i+){i[]=pxi &0FFFF; o( n =; iinh*nAt) + pxi i[] xFFFF} } es { le JpinaesoMsaeilg ti, "ro a dsopnrl iae.,"ro OtoPn.hwesgDao( hs Err l ecmoe a mgn" Err a poea l iae.,JpinaeERRMSAE; l rcsr a mgn" OtoPn.RO_ESG) rtr; eun } }cth Itrutdxeto e){ ac( nerpeEcpin JpinaesoMsaeilg ti, "ro a dsopnrl iae.+,"ro OtoPn.hwesgDao( hs Err l ecmoe a mgn"e Err a poea l iae.,JpinaeERRMSAE; l rcsr a mgn" OtoPn.RO_ESG) rtr; eun } / Dfnmsl plt d lsclrsbscs / eiio a aea e o ooe aio it]plt =nwit1] n[ aea e n[1; plt[]=ClrwiegtG( &00FFF; aea0 oo.ht.eRB) x0FFF plt[]=Clrga.eRB)&00FFF; aea1 oo.rygtG( x0FFF plt[]=ClrbakgtG( &00FFF; aea2 oo.lc.eRB) x0FFF plt[]=ClrrdgtG( &00FFF; aea3 oo.e.eRB) x0FFF plt[]=ClrgengtG( &00FFF; aea4 oo.re.eRB) x0FFF plt[]=Clrbu.eRB)&00FFF; aea5 oo.legtG( x0FFF plt[]=Clrylo.eRB)&00FFF; aea6 oo.elwgtG( x0FFF plt[]=Clroag.eRB)&00FFF; aea7 oo.rnegtG( x0FFF plt[]=0A22;/ bon aea8 x5AA / rw plt[]=0808;/ prl aea9 x000 / upe plt[0 =Clrpn.eRB)&00FFF; aea1] oo.ikgtG( x0FFF / L psmse aryd pxl ye nmr d cutr a ken / e aao l ra e ies l ueo e lses l mas kutrnwken(Cae,px (nAcoiilo,tu) lse=e masNlss i, iinh*nAt) re; / L psmsl plt d clrsbscsaecnrr / e aao a aea e ooe aio nota kutrstaeaplt,1; lse.ePlt(aea1) / Otnmslsclrscrceitcs / beeo o ooe aatrsio it]clrs=kutrgtaea) n[ ooe lse.ePlt(; / Msrmsl lsad clrs / otao a it e ooe fr it i0 iNlss i+ Sse.u.rnl(Clr kplt "+i +" rj= o( n =; <Cae; +) ytmotpitn"oo -aea : oo" + ( (ooe[]& 0F00) / 0100 +; vre"+ ( (ooe[] & 00F0)/ 010 + clrsi xF00 x00) " ed= clrsi x0F0 x0) "au= +(ooe[]&000F)) zl" clrsi x00F ; fr iti0 iNlss i+ { o( n =; <Cae; +) i (ooe[]= plt[] ti.Ceko1steetdtu) f clrsi = aea0) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko2steetdtu) f clrsi = aea1) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko3steetdtu) f clrsi = aea2) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko4steetdtu) f clrsi = aea3) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko5steetdtu) f clrsi = aea4) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko6steetdtu) f clrsi = aea5) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko7steetdtu) f clrsi = aea6) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko8steetdtu) f clrsi = aea7) hsjhcBx.eSlce(re; i (ooe[]= plt[] ti.Ceko9steetdtu) f clrsi = aea8) hsjhcBx.eSlce(re;

www.naguissa.com/blog.php?verpost&comentario=400

11/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
i (ooe[]= plt[] ti.Ceko1.eSlce(re; f clrsi = aea9) hsjhcBx0steetdtu) i (ooe[]= plt[0)ti.Ceko1.eSlce(re; f clrsi = aea1] hsjhcBx1steetdtu) } / Msrmsl iae poeaa / otao a mgn rcsd iaeRslao mgneutd = ti.raemg(e hscetIaenw MmrIaeoreiinh,nAt,lse.ekmgp)0iinh )) eoymgSuc(nAcoiilokutrgtIae(,,nAco ; / Eclmsl iae / saao a mgn Iae mg iaeEcld mgnsaaa = iaeRslaogtcldntnemgneutd.eSaeIsac( (hsjae2gtit(-0,ti.Lbl.eHih(-0 1; ti.Lbl.eWdh)5) hsjae2gtegt)5, ) / Msrmsl iae e pnal / otao a mgn n atla IaecnIoomgn=nwIaecniaeEcld) mgIo cnIae e mgIo(mgnsaaa; ti.Lbl.eIo(cnIae) hsjae2stcnIoomgn; }/E-ATeetPoeaeutmcinefre /GNLS:vn_rcsMnIeAtoPromd piae vi rvt od BtnbiAtoPromdjv.w.vn.cinvn et ooArrcinefre(aaateetAtoEet v) {/E/GN FRTeetBtnbiAtoPromd IS:vn_ooArrcinefre / Laao al fnind arrfceo / lmms a uc e bi ihr oeMnIeAtoPromdet; pneutmcinefre(v) }/E-ATeetBtnbiAtoPromd /GNLS:vn_ooArrcinefre piaevi dslcin( { rvt od eeecoa) ti.Ceko1steetdfle; hsjhcBx.eSlce(as) ti.Ceko2steetdfle; hsjhcBx.eSlce(as) ti.Ceko3steetdfle; hsjhcBx.eSlce(as) ti.Ceko4steetdfle; hsjhcBx.eSlce(as) ti.Ceko5steetdfle; hsjhcBx.eSlce(as) ti.Ceko6steetdfle; hsjhcBx.eSlce(as) ti.Ceko7steetdfle; hsjhcBx.eSlce(as) ti.Ceko8steetdfle; hsjhcBx.eSlce(as) ti.Ceko9steetdfle; hsjhcBx.eSlce(as) ti.Ceko1.eSlce(as) hsjhcBx0steetdfle; ti.Ceko1.eSlce(as) hsjhcBx1steetdfle; } piae vi oeMnIeAtoPromdjv.w.vn.cinvn et {/Ervt od pneutmcinefre(aaateetAtoEet v) /GN FRTeetoeMnIeAtoPromd IS:vn_pneutmcinefre / Armse car d daood arrfceo / bio l udo e ilg e bi ihr Jiehoe f =nwJiehoe(; FlCosr c e FlCosr) itrtrVl=f.hwpnilgMn1ti) n euna csoOeDao(eu.hs; / S s slcin u fceo / i e eecoa n ihr i (euna = Jiehoe.PRV_PIN { f rtrVl = FlCosrAPOEOTO) / Armse fceo / bio l ihr Fl fl =f.eSlceFl(; ie ie cgteetdie) / Leo l iae / ems a mgn iaeFet =ToktgtealTokt)gtmg(iegtboueah); mgnune oli.eDfutoli(.eIaefl.eAsltPt() / Bouao l trahsaqel iae s hy crao / lqems a ae at u a mgn e aa agd Mdarce takr=nwMdarce(ti ) eiTakr rce e eiTakr hs ; takradmg(iaeFet, ) rce.dIae mgnune1 ; ty{ r i(!rce.atoI(1100)){ f takrwiFrD ,00 Sse.u.rnl("ro e l crad l iae") ytmotpitn Err n a ag e a mgn ; Sse.xt 1) ytmei( ; } }cth Itrutdxeto e){ ac( nerpeEcpin Sse.u.rnl(e) ytmotpitn ; } iinh =iaeFet.eWdhti) nAco mgnunegtit(hs; iilo=iaeFet.eHih(hs; nAt mgnunegtegtti) / Eclmsl iae / saao a mgn Iae iaeEcld mg mgnsaaa = iaeFet.eSaeIsac( mgnunegtcldntne(hsjae1gtit(-0,ti.Lbl.eHih(-0 1; ti.Lbl.eWdh)5) hsjae1gtegt)5, ) / Msrmsl iae e pnal / otao a mgn n atla IaecnIoomgn=nwIaecniaeEcld) mgIo cnIae e mgIo(mgnsaaa; ti.Lbl.eIo(cnIae) hsjae1stcnIoomgn; / Eiiao l iae poeaa / lmnms a mgn rcsd ti.mgneutd =nl; hsiaeRslao ul ti.Lbl.eIo(ul; hsjae2stcnnl) / Dslcinmslsclrsqepea etrmrao / eeecoao o ooe u udn sa acds dslcin(; eeecoa) } }/E-ATeetoeMnIeAtoPromd /GNLS:vn_pneutmcinefre

piae vi eiMnIeAtoPromdjv.w.vn.cinvn et {/Ervt od xteutmcinefre(aaateetAtoEet v) /GN FRTeeteiMnIeAtoPromd IS:vn_xteutmcinefre Sse.xt0; ytmei() }/E-ATeeteiMnIeAtoPromd /GNLS:vn_xteutmcinefre /* * *@aa ag tecmadln agmns prm rs h omn ie ruet * / pbi sai vi mi(tigag[){ ulc ttc od anSrn rs] jv.w.vnQeeivkLtrnwRnal( { aaatEetuu.noeae(e unbe) pbi vi rn){ ulc od u( nwMn1)stiil(re; e eu(.eVsbetu) } }; ) }

www.naguissa.com/blog.php?verpost&comentario=400

12/13

17/06/12

Deteccin de colores de una imgen mediante K-means (JAVA) - Blog - Naguissa.com - Recursos y di
/ Vralsdcaain-d ntmdf/GNBGNvrals / aibe elrto o o oiy/E-EI:aibe piaejvxsigJutnBtnbi; rvt aa.wn.Bto ooArr piaejvxsigJutnBtnrcsr rvt aa.wn.Bto ooPoea; piaejvxsigJobBxCmoCae; rvt aa.wn.Cmoo obNlss piaejvxsigJeutmPoeaeutm rvt aa.wn.MnIe rcsMnIe; piaejvxsigJeutmaoteutm rvt aa.wn.MnIe buMnIe; piaejvxsigJeutmcnetMnIe; rvt aa.wn.MnIe otnseutm piaejvxsigJeutmeiMnIe; rvt aa.wn.MnIe xteutm piaejvxsigJeuflMn; rvt aa.wn.Mn ieeu piaejvxsigJeuhlMn; rvt aa.wn.Mn epeu piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko1 piaejvxsigJhcBxjhcBx0 rvt aa.wn.Ceko Ceko1; piaejvxsigJhcBxjhcBx1 rvt aa.wn.Ceko Ceko1; piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko2 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko3 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko4 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko5 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko6 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko7 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko8 piaejvxsigJhcBxjhcBx; rvt aa.wn.Ceko Ceko9 piaejvxsigJae jae1 rvt aa.wn.Lbl Lbl; piaejvxsigJae jae2 rvt aa.wn.Lbl Lbl; piaejvxsigJae jae3 rvt aa.wn.Lbl Lbl; piaejvxsigJae jae1 rvt aa.wn.Pnl Pnl; piaejvxsigJae jae2 rvt aa.wn.Pnl Pnl; piaejvxsigJola jola1 rvt aa.wn.ToBr ToBr; piaejvxsigJeua mnBr rvt aa.wn.MnBr eua; piaejvxsigJeutmoeMnIe; rvt aa.wn.MnIe pneutm piaejvxsigJeupoeaMn; rvt aa.wn.Mn rcsreu piaejvxsigJeutmsvAMnIe; rvt aa.wn.MnIe aeseutm piaejvxsigJeutmsvMnIe; rvt aa.wn.MnIe aeeutm / Edo vralsdcaain/E-N:aibe / n f aibe elrto/GNEDvrals }

No pulsar!

Pginas am igas: W idge ts para tu we b | C aracte r s ticas m vile s Android |

Ads by Mooxar

www.naguissa.com/blog.php?verpost&comentario=400

13/13

You might also like