51 - Image Segmentation using K-means

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 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

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

  • @azitafazelkhah2874
    @azitafazelkhah2874 2 ปีที่แล้ว +1

    Amazing tutorial! Thank you sir.

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

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

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

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

  • @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: th-cam.com/video/H_L7V_BH9pc/w-d-xo.html

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

  • @deepikagupta8895
    @deepikagupta8895 ปีที่แล้ว

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

  • @justinm2015
    @justinm2015 4 ปีที่แล้ว +2

    dope

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

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

  • @PG-iq6zv
    @PG-iq6zv 4 ปีที่แล้ว +1

    I love your channel very helpfull, thank you!

  • @iftikharhumayun5558
    @iftikharhumayun5558 4 ปีที่แล้ว

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

  • @alaarabie2185
    @alaarabie2185 3 ปีที่แล้ว

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

  • @alexadanielaespinozacebrer9001
    @alexadanielaespinozacebrer9001 ปีที่แล้ว

    te amo

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

  • @michaelmanuel1676
    @michaelmanuel1676 3 ปีที่แล้ว

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

  • @nayanjyotigogoi-m6h
    @nayanjyotigogoi-m6h 10 หลายเดือนก่อน

    where can i find the image used

    • @DigitalSreeni
      @DigitalSreeni  10 หลายเดือนก่อน

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

  • @claudioabado3317
    @claudioabado3317 ปีที่แล้ว

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

  • @rameshwarsingh5859
    @rameshwarsingh5859 3 ปีที่แล้ว

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

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

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

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

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

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

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

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

  • @HarishS12137
    @HarishS12137 4 ปีที่แล้ว +2

    explained in detail, thank you so much!!

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

  • @Hadi-wn2hw
    @Hadi-wn2hw 2 ปีที่แล้ว

    Sir, ap kamal hn

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

  • @choogiesaur
    @choogiesaur 4 ปีที่แล้ว

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

  • @iamsrk1474
    @iamsrk1474 4 ปีที่แล้ว

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

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

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

  • @殺氣仔
    @殺氣仔 2 ปีที่แล้ว

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