51 - Image Segmentation using K-means

Поделиться
HTML-код
  • Опубликовано: 21 сен 2024

Комментарии • 80

  • @AlexanderMoen
    @AlexanderMoen 4 года назад +11

    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 :)

  • @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!!

  • @chemworld4773
    @chemworld4773 3 года назад +1

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

  • @azitafazelkhah2874
    @azitafazelkhah2874 2 года назад +1

    Amazing tutorial! Thank you sir.

  • @choogiesaur
    @choogiesaur 4 года назад

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

  • @rameshwarsingh5859
    @rameshwarsingh5859 3 года назад

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

  • @claudioabado3317
    @claudioabado3317 Год назад

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

  • @HarishS12137
    @HarishS12137 4 года назад +2

    explained in detail, thank you so much!!

  • @MrNouhsabri
    @MrNouhsabri 2 года назад

    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.

  • @michaelmanuel1676
    @michaelmanuel1676 3 года назад

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

  • @fahadp7454
    @fahadp7454 Год назад

    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?

  • @PG-iq6zv
    @PG-iq6zv 4 года назад +1

    I love your channel very helpfull, thank you!

  • @max_nadolny
    @max_nadolny Год назад

    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?

  • @리레오-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)

  • @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

  • @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: ruclips.net/video/H_L7V_BH9pc/видео.html

  • @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?

  • @deepikagupta8895
    @deepikagupta8895 Год назад

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

  • @iftikharhumayun5558
    @iftikharhumayun5558 4 года назад

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

  • @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.

  • @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?

  • @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 Год назад

      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.

  • @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!!

  • @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.

  • @justinm2015
    @justinm2015 3 года назад +2

    dope

  • @Hadi-wn2hw
    @Hadi-wn2hw 2 года назад

    Sir, ap kamal hn

  • @殺氣仔
    @殺氣仔 2 года назад

    How can I seperate every ncluster(K) as masks?

  • @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

  • @alaarabie2185
    @alaarabie2185 3 года назад

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

  • @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.

  • @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.

  • @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

  • @alexadanielaespinozacebrer9001

    te amo

  • @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!

  • @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

  • @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.

  • @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?

  • @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.

  • @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.

  • @nayanjyotigogoi-m6h
    @nayanjyotigogoi-m6h 9 месяцев назад

    where can i find the image used

    • @DigitalSreeni
      @DigitalSreeni  9 месяцев назад

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

  • @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.

  • @iamsrk1474
    @iamsrk1474 4 года назад

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

  • @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