51 - Image Segmentation using K-means

Поділитися
Вставка

КОМЕНТАРІ • 80

  • @joker345172
    @joker345172 3 роки тому +6

    Damn, this saved my research project. Thank you so much for the simple explanation, most k-means videos on youtube don't use images directly and that was killing me until I found your video. Thanks so much for the awesome content, you've helped me a lot today!!

  • @AlexanderMoen
    @AlexanderMoen 4 роки тому +12

    man, I've literally been spending hours trying to figure out how to do this, and you easily and simply knocked this out for me in no time. Not only that, it was done in a way that makes sense and was easy to follow. I've never used cv2 before and had to install everything, but this was incredibly useful. Liked and favorited. Keep up the good work

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому

      Thanks. I am glad you found my channel. Now time to tell your friends about it :)

  • @chemworld4773
    @chemworld4773 3 роки тому +1

    Thank you for all amazing tutorials. Here I request to give tutorials on active contour models

  • @fahadp7454
    @fahadp7454 2 роки тому

    Third arguement is criteria in the syntax, why is it 'None' here, and criteria is only 4th even in sample code given in official website (openCV). What does None specify?

  • @리레오-u4w
    @리레오-u4w Рік тому

    Could I get size information directly from segmented image gotten by k means clustering method? I think it is difficult to get clear contour line in case of noisy grain (mixed labels in grain)

  • @azitafazelkhah2874
    @azitafazelkhah2874 3 роки тому +1

    Amazing tutorial! Thank you sir.

  • @max_nadolny
    @max_nadolny 2 роки тому

    Hi. How to use 5 dimensions feature space with kmeans. For instance r,g,b,x,y. To add more features is simple - just add one column per feature to array. But how to reconstruct image back after segmentation?

  • @choogiesaur
    @choogiesaur 4 роки тому

    Very clear and useful video to get me started on segmentation. Cheers!!

  • @tchintchie
    @tchintchie 4 роки тому +1

    amazing tutorial! is there any way to display the clusters in color?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому +1

      If you mean displaying image pixels in color then just use any colormap that you like. Or you can use the process from video 23 where I assigned specific pixel value to each segmented region.
      If you are referring to plotting clusters where data points are different colors, you can watch my video from my work account: ua-cam.com/video/H_L7V_BH9pc/v-deo.html

  • @rameshwarsingh5859
    @rameshwarsingh5859 3 роки тому

    ☕.thanks Sreeni Sir. yiu gave a Channel to Motivate Students Towards HEALTH AND SCIENCE

  • @kaziranga_national_park
    @kaziranga_national_park 2 роки тому

    Sir, how to similarity animal photographs segregation move to folderwise. Example Tiger, elephant, deer, buffalo, wild pig, etc. Can you possible. please help

  • @beltansaxophonequartet6150
    @beltansaxophonequartet6150 3 роки тому +1

    Thanks a lot for the video, I have a technical question: what is exactly center[label.flatten()] in line 26 doing?
    How can this synthax return a 751000 x 3 array?
    Thanks, it's probably some interpretation of the numpy arrays manipulation that I'm missing.

    • @felipesb2
      @felipesb2 2 роки тому

      I was trying to understand this too on my code. I was expecting that center = center of each cluster. But it's actually the "mean value" of color in the original image at that cluster area.
      So, the values you have at center variable are the colors of the clusters. for example: (255, 255, 255) if its a white cluster. If you have 4 clusters, you gonna have 4 colours on this list. Indexes: 0, 1, 2, 3
      The label is a variable that has the same shape of img2. But it only carries the information of which cluster each pixel is linked.
      So if you have 4 clusters, on a 10x1 (1 channel image), array, it might look like this:
      label = [0,0,1,3,2,3,3,3,2,1]
      When he uses center[label.flaten()] he applies the label values as a index to choose the right color of the cluster on each position. And saves the result of this on "res" list.

  • @HarishS12137
    @HarishS12137 5 років тому +2

    explained in detail, thank you so much!!

  • @alviahmedabir2085
    @alviahmedabir2085 4 роки тому

    How effective is the image segmentation method for determining if a pv panel is dirty and classifying the type of soiling?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому +1

      Depends on how images look, if you can manually classify them then there is a good chance they can be automatically classified using image processing. We do this all the time in many fields, for example classifying the type of nuclei in biology or classification of mineralogy based on texture in geology. Deep learning may be required.

    • @alviahmedabir2085
      @alviahmedabir2085 4 роки тому

      @@DigitalSreeni Yes, sir. They can be manually classified. Thank you for the reply.

  • @shankaraggarwal4234
    @shankaraggarwal4234 3 роки тому

    Can we segment malaria blood smear images using this method

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      I am not aware of how these images would look like. Give it a try and check it out.

  • @claudioabado3317
    @claudioabado3317 Рік тому

    Wow! Thank you so much for explaining patiently :-)

  • @MrNouhsabri
    @MrNouhsabri 3 роки тому

    I have two labelled classes, I need for each class to be segmented into 2 subclasses using the KMeans. so class 1 would be class1_1 and class1_2 and so on. Thanks in advance.

  • @nehachowdary558
    @nehachowdary558 3 роки тому

    Can we perform classification on segmented images? I mean, can we feed the segmented images to the svm classifier? If yes, then from the segmented images, how will the svm or any classifier, classify the images?

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      Yes you can use segmented images as input to another machine learning pipeline. If your classification is based on number of pixels corresponding to a given class then it makes sense. But if you want to classify images as cats/dogs or nucleus/mitochondria or other application, then it makes sense to work directly with raw images. This is because original raw images will have many features that are important for classification.

    • @nehachowdary558
      @nehachowdary558 3 роки тому

      @@DigitalSreeni Thank you so much! Can I get your email id, so that I can reach out to you for the doubts I have regarding the project that I'm working on?

  • @nehachowdary558
    @nehachowdary558 3 роки тому

    Since you're working on RGB image, you reshaped it to (-1, 3) because the 3 represents r, b, g channels. But for grey scale images how should I reshape it? Can you please answer this?

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому +2

      Passing -1 for reshaping numpy array means that we do not know what that number is going to be. In this case I want to collapse my data into some (unknown, 3), so I passed -1. In your case, if you only have 1 channel and want the output to be (unknown, 1) then pass (-1,1). If you just want to convert to single vector, then just flatten - np.flatten(array).

    • @nehachowdary558
      @nehachowdary558 3 роки тому

      @@DigitalSreeni Understood. Thank you so much. And your videos are helping me so so much for my project. Thank you!!

  • @Poojasrinivas26
    @Poojasrinivas26 3 роки тому

    Sir where did we get that document,can u post it in description or else in comment box please sir

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      Which document? If you are referring to the image then I just got it from Google search: deben.co.uk/wp-content/uploads/2012/07/BS-Image-lrg.jpg

    • @Poojasrinivas26
      @Poojasrinivas26 3 роки тому

      Not this that code present document

  • @arcanas213
    @arcanas213 4 роки тому

    Hello, is it possible to create contours/masks from the created clusters ?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому

      Well, you can treat the segmented images as masks.

    • @arcanas213
      @arcanas213 4 роки тому

      @@DigitalSreeni Thank you very much for the reply!

  • @nayanjyotigogoi-m6h
    @nayanjyotigogoi-m6h Рік тому

    where can i find the image used

    • @DigitalSreeni
      @DigitalSreeni  Рік тому

      deben.co.uk/wp-content/uploads/2012/07/BS-Image-lrg.jpg

  • @dattebayo_productions
    @dattebayo_productions 3 роки тому

    Having trouble,it shows error AttributeError: Nonetype object has no attribute 'reshape'

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      Nonetype object means there is no data (image). Please make sure the image is properly read, check the path, etc.

  • @umairsabir3519
    @umairsabir3519 4 роки тому

    Thanks for this interesting video. I was working on some outlier detection problem where DBSCAN gives pretty good result. Any way to do segmentation using DBSCAN clustering in python which could consume reasonable RAM space. The DBSCAN on images explode the memory requirements and hard to implement using sklearn. Any other way ?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому

      I hope you're referring to DBSCAN module from sklearn. DBSCAN is fine for non-image data but can be computationally expensive for images. Any limitations by k-means can be addressed using Gaussian mixture model (GMM). I am not sure how results GMM compares against DBSCAN but computationally it is much faster.

    • @umairsabir3519
      @umairsabir3519 4 роки тому

      @@DigitalSreeni Thanks for the advice. I will try GMM as well.

  • @deepikagupta8895
    @deepikagupta8895 Рік тому

    sir please add video on fuzzy k-mean clustering image segmentation

  • @rs9130
    @rs9130 3 роки тому

    Is it a good way to generate segmentation dataset for cnn? Thank you

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      Sure, you can use this approach to generate data for deep learning but if k-means can solve your segmentation problem why would you need deep learning? I recommend using the simplest approach that solves the problem.

  • @truongthanhtung4519
    @truongthanhtung4519 3 роки тому

    Hi! your video is helpful. Do you have a program for SLIC Algorithms using Python :( I am researching its but it is too hard :( Help me

  • @PG-iq6zv
    @PG-iq6zv 4 роки тому +1

    I love your channel very helpfull, thank you!

  • @Luis-hw5lk
    @Luis-hw5lk 3 роки тому

    can i use Kmeans for a image with only one band ?

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      Yes, you can use k means for single channel images, example grayscale images.

  • @alaarabie2185
    @alaarabie2185 4 роки тому

    What is image j
    How can I do it?
    Thanks a lot

  • @michaelmanuel1676
    @michaelmanuel1676 3 роки тому

    Thank you again! Sir you help me alot again!!

  • @cars_worldcw488
    @cars_worldcw488 4 роки тому

    Please sir, can I apply this segmentation to ''.tif '' image ?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому +2

      Yes, of course. Just read them using scikit-image or tifffile. The rest of the process should be the same.

    • @cars_worldcw488
      @cars_worldcw488 4 роки тому

      @@DigitalSreeni Thank you very much sir for your reply. I want to apply it for multitemporal Sentinel 2 satellite imagery.

  • @iftikharhumayun5558
    @iftikharhumayun5558 4 роки тому

    Kindly use clear images like cat and dog or any thing which can show clear segmentation

  • @sushilkotwal3062
    @sushilkotwal3062 4 роки тому

    canu prepare a video for otsus binarization ?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому +1

      I’ve got 2 videos on otsu, please check other videos on my channel.

  • @XinhLe
    @XinhLe 3 роки тому

    Note: This will not work with the latest python version. Python 3.6 is ok for me. Thanks!

    • @DigitalSreeni
      @DigitalSreeni  3 роки тому

      I just tested it on python3.7 and it works fine. May be you have other issues with your environment?

  • @mahdisghorbanzade5454
    @mahdisghorbanzade5454 4 роки тому

    Hi sir. first I want to thank you for making this tremendously helpful videos. I have one question regarding this video's topic. what is the best way to find the optimal K?

    • @DigitalSreeni
      @DigitalSreeni  4 роки тому +2

      Please watch my video number 53 that explains the process of picking the right number of parameters for unsupervised segmentation, including k-means.

    • @mahdisghorbanzade5454
      @mahdisghorbanzade5454 4 роки тому

      @@DigitalSreeni Thank you very much for the response.

    • @mahdisghorbanzade5454
      @mahdisghorbanzade5454 4 роки тому

      I have one more question.. what method/package do you recommend for k means clustering a 3d matrix?

  • @vinitachauhan2468
    @vinitachauhan2468 5 років тому

    where can i get the whole code ?

    • @choogiesaur
      @choogiesaur 4 роки тому

      just copy it, only a few lines
      but some of it was from here
      opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_ml/py_kmeans/py_kmeans_opencv/py_kmeans_opencv.html

  • @iamsrk1474
    @iamsrk1474 4 роки тому

    What’s the software used is it python or matlab?

  • @teckyify
    @teckyify 4 роки тому +2

    Would actually been have helpful to implement the algorithm by hand, it's not that hard and what's in this video is anyways in the CV docs

  • @Hadi-wn2hw
    @Hadi-wn2hw 3 роки тому

    Sir, ap kamal hn

  • @justinm2015
    @justinm2015 4 роки тому +2

    dope

  • @alexadanielaespinozacebrer9001

    te amo