K-means clustering in Java code found!

My blogpost on K-means clustering has the highest number of views, so people are probably interested in it. Sadly enough I lost the source code of the K-means action a while ago. Last week I needed an external harddisk to make a back-up of some files. There was already some content on the disk. I found quite some pieces of code including the K-means code. Although it is quite simple code operating on (if I remember correctly 8-bit) greyscale images, it might give some insights in how to do this.

The whole code file is presented below. For more information you can view my earlier blogpost on K-means clustering.

The source code might not be completely visible. It can be viewed in a blank screen here. As mentioned in the replies to this post, I forgot to add the ClusterClass. It can be viewed in a blank screen here.

Getagged , , ,

106 reacties op “K-means clustering in Java code found!

  1. Антоха schreef:

    Данный пост очень информативен, спасибо Вам!

    Edit: please in English as other people might benefit from possible questions and / or solutions.
    Translated: This post is very informative, thank you!

  2. pinaka schreef:

    in your programm you have used ClusterClass.what is it?
    when i compile the code it’s giving error

    cannot find symbol:ClusterClass

    what should i do?

  3. Patrick schreef:

    Hi pinaka, thanks for your interest. I’ll look into that as soon as possible. Unfortunately I’ve left my notebook with the code at school. I’ll reply as soon as I’ve solved the issue.


  4. Patrick schreef:

    I see what the issue is: it’s a custom class. I’ll add it tomorrow 🙂

  5. Ivan schreef:

    Hi Patrick,

    really appreciate your k-means clustering in Java because i am planning to implement it into j2me.

    hope you could add the custom class (ClusterClass) soon so i could try it out on the desktop first.


  6. Patrick schreef:

    I’ve updated the post with a link to the file as well as the contents in the post itself. Note that these classes are actually part of an application which I was writing, so they might have been written in the context of this application.

    I would like to continue this application and make it public here some day, but I don’t have the time to do that just now.

    If there are any questions, sugesstions, or whatsoever I’d be glad to hear them!

  7. Prashanth schreef:

    Is it possible for you to give me an equivalent C# code

    • Patrick schreef:


      If I would know how to do it I would. Unfortunately I haven’t had time to learn any version of C yet. However, I guess that the code itself gives a reasonable impression of how to do it in C#.



  8. vinod schreef:

    hello patrick,

    Do u have CURE & CHAMELON clustering algorithm implemented in java

    • Patrick schreef:

      Hi Vinod,

      I’m afraid not. I must admit that I haven’t looked into the code recently. If I’d only have some more time I would. Do you happen to have a clear data source about Cure & Chamelon clustering from which an implementation can be derived?

  9. dekompi schreef:

    Very nice progie.
    But where the main method sir?


  10. Patrick schreef:

    dekompi: As this action is part of an application, the main method is not present in this class. It’s an action class which receives its info from the main frame. The main frame is basically a frame which shows images and adds file options.

  11. Raghotham S schreef:

    Hi Sir,
    I hav a project in college – Image segmentation using kmeans

    i hav the code which u hav posted
    but am not knowin how to pass an image as input
    I need to design an applet which takes image as input and outputs the result.
    pls help its v v urgent.
    Thanks in advance

  12. Raghotham S schreef:

    can u pl giv me a code which can segment image without that histogram input?
    Or else can u explain how to generate histogram for an image?

  13. Patrick schreef:

    Raghotham S:

    The segmentation is done on the histogram. The histogram of an image is basically a ‘graph’ of all pixel values of the image. In greyscale images the red value is equal to the green and the blue value. When having an image with 256 colors, your histogram contains of 256 bins. You simply count the pixels having a red (or green or blue) value of 0, 1, 2, …, 255. I will try and look up the code for the application tonight.

  14. Raghotham S schreef:

    Ok thanks a lot!!

  15. Patrick schreef:

    Raghotham S:

    Full source code can now be found here or at the download page

    Good luck!

  16. […] there was some interest in source code in two earlier posts (post 1, post 2) I've posted the source code […]

  17. Raghotham S schreef:

    Thanks a ton… i owe u 🙂

  18. Raghotham S schreef:

    one last doubt patrick,
    the ispe.java doesn’t work for most of the images whereas the ispe.jar file works well with almost all images. Why is it so?

  19. Raghotham S schreef:

    figured it out 😀
    thanks again for the code 🙂

  20. Patrick schreef:

    Did it have to do with the classpath and the ImageIO jar file in the lib directory?
    That’s what I expected..

  21. Raghotham S schreef:

    it needed a slight modification for the buffered image handling part. 🙂

  22. Chit Su Hlaing schreef:

    Thank you for your open source coeds. Thank you so much! I wish you that you can have the more great logic and think for your great life.

  23. shipra schreef:

    hi! cud u pls tell the logic/concept dat u have used in k mean clustering…(i cud’nt get it 100%..).i tried your code ..it gives very good results..generally its said that k mean gives good result ..depending on the initial seed pixels..but howcome your code gives good result (same) for all three options..K,distributed over color space..,randomly
    …cud u pls elaborate distributed over color space and k..(the theorey part)..
    neways very good prog..

  24. Patrick schreef:


    I don’t think the result is the same for all three types of initialization. That would be a coincidence. What K-means actually tries to do is to find clusters of likely ‘equal’ pixel values. It all depends on the original image histogram. Especially when the mean is distributed over the color space.
    I can’t imagine my code always gives good results for randomly chosen means. In the worst case all means chosen are close to each other and at one side of the histogram.

    Come to think of it: the means could also be chosen in a weighted way. This would perhaps give some good results in all cases.

  25. Gayathri schreef:

    I saw the codings provided by you for the project , “K-Means Clustering by java source codes”. Its very nice. I need one help from you. Now i am doing one project in the area of data mining.In my project K-means clustering algorithm is one of the module. So i need some codings for k-means algorithm , in that the clustering technique is used for clustering large amount of data sets . How can i do it in C language.If you have some idea about it means , please help me,… what i need is “implementation of k-means algorithm for clustering large amount of data points using C”.

    “Awaiting for your reply”


  26. shipra schreef:

    thank u so much!!..for rplying..

  27. Ramesh schreef:

    can you help me in find web user clusters using k-means on web log file

    • Patrick schreef:

      Hi Ramesh,

      Wat is it exactly that you want to cluster? And what are the criteria which determine which piece of data will get into a particular cluster?



  28. gara schreef:

    how to run the code ….m getting error whlinterprting

  29. dharma schreef:

    Hi Patrick sir ..

    now am doing clustering project ..so i need to implement that kmeans algorithms ,,.i have kmeans algorithm which u have posted..but its giving error..Exception in Thread “main”.java.lang.NoClassDefFoundError..so what i can do now,,,
    mar 10 th is my project submission ..
    so so
    please please ..reply as soon as u can sir.please….
    v v v v v v v vy urgent..

  30. Patrick schreef:

    Hi Dharma,

    Which code do you have? The code supplied above?
    The Exception you mention doesn’t seem to be related to that code as far as I can see. Is there some additional information?



  31. dharmaraja.k schreef:

    Sir am having KMeansAction code which is u had posted…

    but am having the problem withe the exception thread…
    GIve me the solutions sir v v vvvvvvvv urgent ….
    10 th project delivery..please help me..sir…

    or send me the procedures..
    in what name to be save and compile the program,,
    the class name..
    how to give input ..

  32. Patrick schreef:


    I cannot give you a direct solution to all your issues. However, I’d suggest that you call your files KMeansAction.java and ClusterClass.java.

    You can also find the package as a whole on the download page, or just here

    It contains both those two classes as well as some code around them. As far as I know (at least back then) it didn’t contain errors.

    Hope this provides some more insights!

  33. vikas schreef:

    hey patrick….
    i wanted 2 knw hw 2 input d histogram in d kmeansaction class…. plz reply it asap its urgent………

  34. Patrick schreef:


    The histogram is just an array with the pixel values as keys and the times they occur as values. As this operates on grey values, the R, G and B values are the same.
    If we take a 256 bit greyscale image, we have 256 colors: (0,0,0), (1,1,1), … , (255,255,255).
    The histogram will therefore contain keys 0 to 255. Each of the keys represents the grey value.

    histogram[0] = 25
    histogram[1] = 14

    histogram[255] = 3

    would mean there are 25 pixels of grey value (0,0,0), 14 pixels of grey value (1,1,1), …. , and 3 pixels which have grey value (255,255,255) in the image.

    Does this help you?



  35. vikas schreef:

    hey thnx 4 ur reply…… bt i also want 2 knw hw 2 gv it as input in d kmeansaction class dat u hv in ur code….. hw 2 generate d histogram of an image nd den gv it as input????????

  36. Patrick schreef:

    How to generate a histogram:

    Create a histogram array with a bin (entry) for each pixel value
    foreach pixel in your image:
    Get the pixel value
    Increment the appropriate bin in the histogram array by one
    end foreach

    Now you have a histogram: just an array where the keys are the pixel values and the values are the times they occur.
    Provide this array to the kmeans action, alongside some vars (number of bins etc.) as mentioned above in the code and it will calculate the clusters.

  37. vikas schreef:

    hey i calculated the histogram as u told and histogram that has been calculated is ryt as i chckd it…… bt nw i m gtng d error dat KMeansAction cannot be instantiated…………. cn u plz explain hw 2 gt rid of dis error…… plz

  38. Patrick schreef:


    It probably has something to do with where you’ve put the class and whether or not you import it. Please have a look at your file structure and your import path. I’ve put my KMeansAction class in a folder / package called ‘actions’. If you have not done so, you should redefine this.

  39. vikas schreef:

    i changed the KMeansAction to place it in d same package Actions bt nw it showing an exception dat KMeansAction can’t b instantiated and applet is not initialized… plz reply soon……

  40. ishani schreef:

    hi pattrick,
    i am getting the following errors on compiling:

    C:Ispe-devsrc>javac mainIspe.java
    mainIspe.java:33: package com.sun.media.imageioimpl.plugins.tiff does not exist

    import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader;
    mainIspe.java:34: package com.sun.media.imageioimpl.plugins.tiff does not exist

    import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi;
    mainIspe.java:343: cannot find symbol
    symbol : class TIFFImageReaderSpi
    location: class main.Ispe
    TIFFImageReaderSpi tiffreaderspi = new TIFFImage
    mainIspe.java:343: cannot find symbol
    symbol : class TIFFImageReaderSpi
    location: class main.Ispe
    TIFFImageReaderSpi tiffreaderspi = new TIFFImage
    mainIspe.java:345: cannot find symbol
    symbol : class TIFFImageReader
    location: class main.Ispe
    TIFFImageReader tiffreader = new TIFFImageReader
    mainIspe.java:345: cannot find symbol
    symbol : class TIFFImageReader
    location: class main.Ispe
    TIFFImageReader tiffreader = new TIFFImageReader
    6 errors

    what should i do now…???
    please help me out…i wud be very grateful to u….

  41. Patrick schreef:

    Hi Ishani,

    It’s clear that apparently the import is not valid any more. Which version of Java are you running?
    I haven’t checked lately if the TIFFImageReader is (re)moved in the latest Java versions.
    Please check which import causes the error. For a quick fix perhaps there are earlier versions of that import which you can supply locally. For a more persistent fix you should find the (new) correct path to the TIFFImageReader class.



  42. ishani schreef:

    i m using jdk1.6.

  43. ishani schreef:

    which version of java hv u used to run this program….???
    nd can u pls tell me how should i modify the code given by you in such a way that it does not deal with .tiff images…
    please reply asap because i have to submit my project by next week….
    i would be highly obliged…..


  44. ishani schreef:

    hi pattrick,
    i have solved the previous problem of tiff package. and it is running well..thnx a lot for that… but now a new problem has cropped up..
    the window that appears on running the programs includes all the options like file,edit,view,help buttons etc but it is not showing the k-means menu button to carry out the k-means clustering operation…
    i am unable to figure out this problem ..the main purpose is to show k-means but it is not showing up…i dont know what went wrong…
    i hv downloaded a jar file jai_imageio-1.1 from the internet and set the classpath to this jar file ,so that the code can import all the tiff class files require..after that, the code is running well and displaying everything except the k-means option..
    what should i do now…????
    pls help me….


  45. Patrick schreef:

    Hi Ishani,

    Glad you’ve figured that one out. It’s always tough to identify those kind of issues.
    When running the application, you should get the options ‘File’, ‘Edit’, ‘View’, ‘Action’, ‘Help’. Is this correct?



  46. ishani schreef:

    hi pattrick,
    i figured out the problem…now its working ..thank u soo much for ur code….it works well ….thnk u sooo much…:):)..I owe u…
    now after this i have to implement image classification using artificial immune system and then compare its result with the k-means clustering method…
    so,do u hv any idea of how to do it with artificial immune system…??


  47. Patrick schreef:

    Hi Ishani,

    No problem, glad it was helpful!
    I’m not familiar with that method. Do you have a link so I can check it out?



  48. ishani schreef:

    here are some links to it:


    2.An Unsupervised Artificial Immune Classifier for Multi …

    and i want to ask one more thing.In your code,u have assigned greyscale values to the clusters ,but if i want to assign rgb color values to the clusters ,then how should i modify the code????…and u have not used the objective function in ur kmeans code.??

  49. ishani schreef:

    hi pattrick,
    how should i change the dimensions of a histogram so that it fits on the screen??????

  50. Patrick schreef:

    Hi Ishani,

    The clusters currently work on greyscale images, by using the property that the R value is equal to the G value and the B value. So as you can see in the code, the R value is used.
    So basically the code works on redscale images 😉
    You could of course adjust this part and by that get a different value which can be clustered.

    What’s the objective function you mentioned exactly?

    The dimensions of a histogram should be relative I think. I have encountered these issues as well, but didn’t fix them any more. (Shame on me). The dimensions of the histogram should be relative to the screen / drawing panel. Based on the dimensions of the drawing panel you should determine the scale for the histogram so that it fits the screen and preserves the histogram itself.

    I will have a look at the articles you provided when I got time to 🙂



  51. ishani schreef:

    Hi pattrick,
    Thanx …nd see the following link for the objective function:
    home.dei.polimi.it/matteucc/Clustering/tutorial…/kmeans.html – 1.In the kmeans clustering problem,the aim is to minimize the objective function so that we get correct results.

  52. Seyi schreef:

    Hi Mr Patrick,
    I’m writing my project and I really need your help. I want to use clustering to segment teeth pixels in an image. I currently use ImageJ (open source GUI )and i want to extend its functionalities by writing additional plugins. I have some tiff images showing both teeth and gum and I need to isolate the teeth only…Is there any way you could help?? I will be very glad if you can kindly assist me + i’m way behind on my project

  53. Patrick schreef:

    Hi Seyi,

    How can I be of any help?
    Regarding the teeth images: which colors (and / or which range of colors?) do the teeth have in the image? And which color(s) (and / or range) does the gum have?



  54. swathi schreef:

    hi ishani,
    i need source code for k-means algorithm in my project work for clustering the images(.jpeg or pgm) so please help me by giving the code that you have developed so far for your work please help me i need urgently for my project

  55. darsha schreef:

    hi sir.. can yo pls provide me the implementation of k-means algorithm for clustering large amount of data .. actu my proj s abt disease prediction. i just want to form 2 clusters .. ppl with disease n ppl dont hv disease based on the attributes.. can yo help me.. java code ll be much helpfull.. thank you sir

  56. Harry potter schreef:

    I want to do network intrusion detection using k-means. Can you provide me with a code?My input is a syslog log file in CSV format. I want cluster the logs into class 1 if a keyword anomaly is found. else into class 2.

  57. Hi darsha,

    First things first: you’ve got to think on which attributes you are going to cluster. As diseases may have many attributes, think of a good one which can really separate the diseases (clusters).
    The problem is actually not on the code. The theory is the most important part here.



  58. Hi Harry potter (wow! THE Harry? ;-))

    Your problem is quite an easy one at first sight, and I don’t know whether K-Means clustering is the best option for this. K-Means clustering clusters data in an iterative fashion. If you have a predefined set of words which are characteristic for network intrusion, you’re basically counting / separating.
    Can you explain what your method would look like? How would you do network intrusion detection step by step?



  59. Harry potter schreef:

    Which algorithm will best suit this intrusion detection sir ? Currently I want to cluster into 2 groups based on simple keyword matching as I said above. How can the code be modified for real time network packets rather than log files?Can you give some useful links sir?

  60. Hmm.. that’s a good one. Clustering is mostly done on a group of data. What exactly do you want to establish with intrusion detection? Would you like to review every request and directly alarm in case of an intrusion? What does the intrusion detection flow look like?

  61. Harry potter schreef:

    Based on the criticality of the message we want to raise an alarm.(i.e)., we need to analyze all the logs and say whether any intrusion has occurred or not?

  62. nicky schreef:

    hi Patrick,
    If you don’t mind, could you also provide the images example and main class for testing?

    thanks anyway for the code 🙂

    • Hi Nicky,

      I don’t know if I still have the images, but they were just 8-bit greyscale images. Any such type image would do.
      The rest of the source code can be found on the downloads page. It’s in the ‘Ispe development source code’ zipfile.



  63. Hi Harry,

    Just saw that you’d posted a reply a while ago, my bad!
    Regarding the syslog file: it’s a CSV. Which columns does it have?

    K-means clustering would in your case just mean that you need to extract a the messages from the CSV file and classify them in two groups. Based on those two groups the real-time detection algorithm would decide whether a detection occurs based on the message.

    And how would you do this real-time? Would you capture the incoming package and check for particular words?

  64. Akash schreef:

    I want to convert grayescale image into binary image ..so can u suggest any solution..!

    • Hi Akash, this is pretty straightforward. At some point in the image histogram you put the ‘splitting point’. Pixelvalues on the one side will become white and on the other side will become black. This is called thresholding. This is also implemented in the ISPE code which is available on my downloads page.



  65. felix schreef:

    I want to convert output image of ispe code into binary image…how it can possible??

    • Hi Felix,

      I took a look at the code and I see that the Window Slicing operation only turns image pixels outside the window to black. Well, it’s not that hard to create a thresholding operation:

      package actions;

      import java.awt.Color;
      import java.awt.image.BufferedImage;

      * Does a thresholding operation. This will set all values below the threshold to 0 (black) and above the threshold to white (255)
      * @author Patrick van Kouteren (http://www.vankouteren.eu)
      public class ThresholdingAction {

      BufferedImage image_temp;

      public ThresholdingAction(BufferedImage image, int threshold) {
      image_temp = image;
      createNewImage(image, threshold);

      private void createNewImage(BufferedImage image, int threshold) {
      for (int h = 0; h < image.getHeight(); h++) { for (int w = 0; w < image.getWidth(); w++) { Color rgb = new Color(image.getRGB(w, h)); int grey = rgb.getRed(); if (!(grey < threshold)) { grey = 0; } else { grey = 255; } image_temp.setRGB(w, h, (new Color(grey, grey, grey)).getRGB()); } } } public BufferedImage getResultImage() { return image_temp; } } Note that I've created this on the fly (no testing, just writing this out of my head), so you'll need to test this, as well as create the dialog for it and add it to the main Ispe.java class, but I think this code is the main thing you are looking for. I'll add it to ISPE later on. Cheers, Patrick

  66. Shital schreef:

    Thanks Patrick, I got binary image.
    I want to remove noise from that image.
    Please help me…

    Someone told me use dilation technique after getting binary image. But I dont know how to use that tech…

    • Hi Shital,

      Dilation and erosion are common techniques to remove noise from images. They’re often used together. When performing dilation, you add pixels to the borders. When performing erosion, you remove pixels from the borders.
      If you combine these operations you can remove noise from an image:
      Let’s say you have noise which has the form of 3 x 3 pixels blocks. If you then perform an erosion operation in which you remove 2 pixels from the borders, the noise pixels would disappear. That’s great, but remember that the other objects also are smaller now. By performing a dilation in which you add 2 pixels to the borders, the other objects will grow again, but noise isn’t present any more.

      The above example is pretty theoretical. In practice, you would use a kernel for erosion and dilation operations. The kernel defines a form which in its turn defines which pixels will appear or disappear in the dilation and erosion operations. It’s wise to take a look at kernels. It isn’t hard to understand.

      I would like to implement these operations in my ISPE project and I will do so when I find time for the implementation.
      If you have any more questions, please reply 🙂



  67. Kay schreef:

    Hi Patrick,

    I found your site when googling on K-Mean Vector Quantization …

    Currently my homework is to convert 320 x 400 pixel black and white image to smaller size (as in 1mb bcome 100kb) …

    I have the K value and block value … i dunno how to convert 320 x 400 into 4 x 4 pixel per block … and assign randomly to K value … can you advised on this?

    • Hi Kay,

      If I understand correctly you have two ‘issues’, namely:
      1) Convert the image to an image based on blocks
      2) Do K-means clustering

      My first question: how can you create an image built out of 4×4 blocks when the resolution is 320 x 400? The ratio is 4:5. I would expect 4×5 pixel blocks as this makes it easier for you.
      When you have these blocks, these have a value (how do you determine the value?) and the K-means clustering can be performed on those block values when you know the K value.
      Your K-value just means that you have K clusters in which your data points will be clustered. You can initially just assign a random cluster to all data points (which are your blocks) and run the algorithm.

      If you need any more help, just reply 🙂



  68. Vinodh.N schreef:

    hi patrick . all i want to know is the source code of kmeans to implement it in my application(cancer dataset)…

  69. Amol schreef:

    I want to remove noise from that image.
    Please help me…

    I want to use dilation technique after getting binary image. But I dont know how to use it. Please Reply

  70. Mandar schreef:

    I used K means for clustering. Now i want to do dilation and erosion technique. I failed to implement it. So please help me to do this.

  71. samia schreef:

    slt j’ai besoin d’une implémentation des relation de performances pour implémenter l’algorithme k means et l’algorithme k médoïd.

  72. This K Medoids method is interesting as well! I’ll try and take a look at it as soon as possible. I’ll also write a blogpost about erosion and dilation. This is fairly easy. Next to that I’ll pick up the ISPE application code and implement erosion and dilation in it.
    Unfortunately I cannot tell when I’ll be doing this as I’m quite busy at the moment.

    Thanks for all replies and requests. Really cool to see my blogpost is still useful nowadays 🙂

  73. Shital schreef:

    Hello Patrick,

    Thanx for your help. Now, I will show what I did till now…

    my input image is here:

    extracted road clusters from above image..
    and I am here now!!!

    First of all I have used K-means algorithm then used thresholding.
    I want to remove non-road elements and noise from the image below..

    Please help me….


  74. Shital schreef:

    Hi Patrick,
    sorry links in above comment are not working..

    please give me solution to following prob..


    thank you…

  75. Philippe schreef:

    You can also check the Java K-Means implementation on my website:


    It offers 47 data mining algorithms.

  76. sravani schreef:

    can u provide the code for incremental k means clustering.

  77. vinoth schreef:

    can u send me how to execute this code.. and the software version to use this code.. the complete steps to execute this code..

    • Hi Vinoth,

      Have you downloaded the source code from the download page? Running it is pretty basic. For an example how it works in an application, you can download the Ispe development source code from the download page. This uses the clustering algorithm from this blogpost!

  78. Pooja schreef:

    I have calculated color histogram of an image and next step is to implement weighted Kmeans clustering,so can you suggest me how to implement Kmeans clustering on RGB histogram. Here the number of bins (k) is not known initially.Instead of that sampling pixel set is input from which we have to randomly choose cluster centers and go on reduncing clusters. Cubical area around the Cluster center with radius 32 is used to cluster the points together.

    Thanking You!

  79. farah schreef:

    hi patrick,
    I’m doing my kmeans project for blood cell image segmentation. I’m running this with ur ispe programme but i keep getting ‘error occur while processing this image!’ while using the image data..i’m using the coloured image. just wondering if this programme works well with coloured image too?if yes then what might be the problem of this?
    Thanks anyway for this brilliant programme..

    • Hi farah,

      The ISPE application actually turns a coloured image into a greyscale image, so technically speaking it works with coloured images, but it actually doesn’t use the colors.
      If I recall correctly I’ve had similar issues before with large images. Having said that: I’ve written the code back in 2007, so there must be more up to date libraries at this time which may handle larger images better. You could try to give Java more memory, or get the source and try to incorporate a more recent image processing library.



  80. farah schreef:

    hi patrick,
    yeah u got it right with the memory issue and i managed to solve it. right now i’m working with this enhanced kmeans and i’m looking to make some adjustment at the point of the initialization stage (k-value)…do u have any idea if i want to make it independent variable?


  81. asa schreef:

    hi this code is nice,
    i dono which main prog to run
    can u plz help

  82. Hi asa,

    The main method is part of the ISPE code. You can download it at downloads page.



  83. farah schreef:

    hi patrick,
    My interest is on the K based on information in the image.Do u have any idea how to modify it or which part that i should focus on.


  84. Hi farah,

    I’m not sure I fully understand your question. What are your intentions: do you determine this K beforehand? And based on which information?



  85. Riadh schreef:

    Hi patrick,thank you for this post,it is verry helpful ,please i need to use k-means :classification of images please contact me

  86. shree schreef:

    hi sir,
    i’m doing my project on opinion mining and i want to cluster the opinions into positive and negative. is it possible to use your code with opinions as input?

  87. danhbk90 schreef:

    dear .
    k-means-clustering can predict stock?
    if can..you can help you?


  88. C.Adisivan schreef:

    public KMeansAction(BufferedImage image, int bins, int[]histogram, int initway)

    how to pass parameter to this above function(By using what parameter i should invoke the above function?

    BufferedImage image=?
    int bins=?
    int[]histogram= what type of array, how to give that array?
    int initway=?

  89. elakky schreef:

    hi patrick
    i am doing one project that using k-means after compression of images i don’t know what i do in this project please help me

  90. jayaram schreef:

    i am very much new to programming interested in implementing kmeans in java which takes input textfile/csv and no. of clusters as command line args , input file containing rows as each such as no, gender, employed (or/not),a/c holder or/not etc with values
    a000,1,1,1,1,110 etc

  91. sindhu schreef:

    hi patrick
    iam doing my project in k means. i want to know how can i clusters the group of string. could u pls explain it.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *