23 - Histogram based image segmentation in Python

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 93

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

    I am loving this series of lectures. I have watched many videos but I would get frustrated and quit but you explain it a really easy way which keeps me going

  • @khalidal-reemi3361
    @khalidal-reemi3361 4 роки тому +1

    Awesome !!. I will never regret following your channel and watching your videos.

  • @성동원
    @성동원 3 роки тому

    감사합니다.

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

      Thank you very much for your kind contribution. Please keep watching the channel.

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

    Very underrated channel! Awesome content

  • @waqarmirza390
    @waqarmirza390 4 роки тому +4

    Really appreciate your effort. Thank you for giving such a informative tutorial.. Thumbs up for the great work

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

      Thank you man for your encouraging feedback. I hope you're learning something and adding coding as a skill set to your portfolio.

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

    Those morphological operations, besides the obvious noise reduction, they also change the contours of the different segment areas (even if those two processes seem to cancel each other). In medical usage or other delicate segmentation applications where the exact limits are important these demand proper "zoom" to see the real impact.

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

    the best as always, thanks so much Digital Sreeni 😍
    great contribution!

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

    HI Srini, thanks for the wonderful session. I got up an error while trying your code. the error is at binary segmentation classification "all_segments[segm1] = (1,0,0)" at this line.
    and the error is "NumPy boolean array indexing assignment cannot assign 3 input values to the 86201 output values where the mask is true".

    • @nadrahshitwi7907
      @nadrahshitwi7907 2 роки тому +2

      for me I tried img2 = cv2.imread("images/BSE_Google_noisy.jpg")
      img = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
      and its worked
      and also I change multichannel=True to channel_axis=None

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

      @@nadrahshitwi7907 Its working...
      Thank you

    • @alqudude16
      @alqudude16 2 місяці тому

      @@nadrahshitwi7907 You're a Legend

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

    Super useful. Thanks so much. Continue be this great

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

    Hi ,some people may ask why the error "NumPy boolean array indexing assignment cannot.." shows up.
    Well when you check the variable area your size is wrong.You only need to convert your image with a color.rgb2gray.Now the sizes are correct.
    Your videos are incredible ,big big thanks sir

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

      Thanks for the critical yet encouraging feedback Pedro.

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

      @@DigitalSreeni how can i Do this ... (""" boolean index did not match indexed array along dimension 2; dimension is 3 but corresponding boolean dimension is 4 """"")
      I'm Getting this error...at the segmentation stage..

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

      @@waqarmirza390 Not sure how to answer without knowing the exact issue. You need to print results after every step and have a look at the variables in the variable explorer. Make sure the dimensions are correct before proceeding. Eventually you will be performing some sort of matrix operation (addition or multiplication or something else); if your dimensions are not right then you cannot perform some tasks. Therefore, you need to confirm the logic. If you are a biologist you will have some issues with learning initially but I hope you can overcome them.

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

      Someone or I can have a look if you can share the image.

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

      @@DigitalSreeni Thank you sir for your response, I'm going through some troubleshooting to eliminate the error, ...Again really appreciate your work sir.. Sir I'm a engineering student major electrical with interest fields of AI and Computer vision , currently doing a project on Brain Tumor Segmentation with our own dataset, and trying to enhance the output efficiency..
      Yes, new to this field so sir your videos are real source of help for me.. Thanks a lot.

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

    I am curious as to why you selected multichannel = True when you performed denoising, even though your image only has one channel? Thank you.

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

      Setting multichannel to True would not hurt even if the image is a single channel. I usually leave it to True just in case if my next image happens to be multichannel.

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

    Awesome! Thank you for the great work. I wonder why the binary image after the open and close operation has some black points?

  • @DeathlessLife786
    @DeathlessLife786 Рік тому +1

    While run the code , i am getting the following error.
    all_segments[segm1] = (1,0,0)
    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 783255 output values where the mask is true
    Can any one help me to short it out?

    • @reevise
      @reevise 6 місяців тому +1

      "Don't know if you still need, but I fixed it by setting as_gray = True in io.imread"

    • @pravinmaske807
      @pravinmaske807 6 місяців тому

      @@reevise Thank you. I was looking for this solution

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

    Sir, can you please help me that why my histograms plot coming upside down.

  • @lukehyde6942
    @lukehyde6942 6 місяців тому

    multichannel isn't recognized and when I change to channel_axis = -1, I get "Non-local means denoising is only implemented for 2D, 3D or 4D grayscale or multichannel images."

    • @reevise
      @reevise 6 місяців тому

      why -1 ? try channel_axis = 2 or 1 or None

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

    Thanks for the video. When i try to show the histogram, it becomes a straight line and no bars are there. Could you please help me?

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

    How can we handle an image which has multiple bands (in my case 8 bands)? This example shows that the image is single band (row*col). Could you prepare a video where you deal with image which has at least 4 bands, so i would learn how to read those files with multiple bands, and how to get segmentation result as one single band.

  • @AshutoshKumarGupta-c9y
    @AshutoshKumarGupta-c9y Рік тому

    Hey! Is there any way to calculate the area of colored segmented images?
    Thumbs up for the great work. I really appreciate your effort.

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

    Thanks for awesome video,i have something in my mind to ask.What is x and y axis of the histogram? number of pixels and what?

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

      x is the pixel value and y is the frequency of that pixel value (how many times does that pixel value show up in the image).

  • @EkaterinaGolubeva-pr9ih
    @EkaterinaGolubeva-pr9ih 2 роки тому

    Can you provide the link towards the image you're processing please ? Where can I find it ? Thanks very much for your work !

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

      Just google search for "SEM BSE image". Here is the direct link: deben.co.uk/wp-content/uploads/2012/07/BS-Image-lrg.jpg

    • @EkaterinaGolubeva-pr9ih
      @EkaterinaGolubeva-pr9ih 2 роки тому

      @@DigitalSreeni thank you very much for your answer. Could you please also provide a link where all the images you use are ? Are they all available at your github (couldn't find them)? I'm watching the whole playlist for my masters thesis and it would be very helpful 😅

    • @EkaterinaGolubeva-pr9ih
      @EkaterinaGolubeva-pr9ih 2 роки тому

      Dear@@DigitalSreeni , is it possible to ask you for the versions of the packages that you used (The requirements text file ), please ?

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

    all_segments[segm1] = (1,0,0)
    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 35136 output values where the mask is true
    Sir I get this error

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

      the segment creation part of the code is not working

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

      same here , i am also getting similar error , if you are able to solve it , pls share your findings

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

      @@smratikatiyar change the multichannel=False

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

    Clusterization or quantification rather than segementation; also these "segments" share common coordinates after thoses morphologic operations, there are not uniques to one "segment".

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

    Hi sir! is there any way to share the images you're working on?

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

    Can histogram segmenatation be genralised to any given image?
    Or is it that we have to manually check the histogram range and then modify it accordingly

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

      It can be generalized to any image, you are just looking at the histogram and thresholding various ranges that represent various segments.

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

    Thank you Sreeni you're awesome.

  • @EkaterinaGolubeva-pr9ih
    @EkaterinaGolubeva-pr9ih 2 роки тому

    Dear Professor, could I please ask you to provide the versions of the packages that you use so I can use the same code as you ? I think the requirements text file can be generated if one writes pip freeze. Also would be very helpful if there was a link to all the images you use for processing. Thank you very much for your work !

    • @nitishgupta169
      @nitishgupta169 2 роки тому +1

      all the images are there in the github resource in the description

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

    Thank you very much sir for your good work. Your video tutorial helped me a lot.
    In the video, you can combine a maximum of 8 different colours, so 2^3 = 8, (0,0,0); (0,1,0); (0,0,1); (0,1,1); (1,0,0); (1,0,1); (1,1,0) and (1,1,1). If I have a segmented image with more than 8 colours (so 22 different colours in total), how do I get this colour?
    Thanks a lot!

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

    getting this error:
    NotImplementedError: Non-local means denoising is only implemented for 2D, 3D or 4D grayscale or multichannel images.
    anyone know how to resolve it?

    • @assiachafi7767
      @assiachafi7767 Рік тому +2

      I set the "multichannel" parameter to False

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

      @@assiachafi7767 yes I also did hit and trial: setting it to false & it worked 😁😁

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

    Hi Sreeni, I am using your code on my image however, I get a ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 590550 output values where the mask is true. I don't know what does it mean and how to fix it. Please help.

    • @gabrielmagal5690
      @gabrielmagal5690 10 місяців тому +1

      Don't know if you still need, but I fixed it by setting as_gray = True in io.imread

    • @reevise
      @reevise 6 місяців тому

      @@gabrielmagal5690 Thank you very much!

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

    Noticed a bunch of untreated (black) pixels after open-closing operation. Those should take the nearest color, maybe?

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

      Yes. We need to perform image processing operations to take care of any remaining isolated pixels.

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

    Hello, thank you sir for sharing information.
    I was trying to implement the similar code but during execution I got one error, can you please help me. I am having following error:
    1 all_segments[seg1] = (1,0,0)
    2 all_segments[seg2] = (0,1,0)
    3 all_segments[seg3] = (1,0,0)
    4 all_segments[seg4] = (0,1,1)
    5
    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 589362 output values where the mask is true

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

      You normally get that error when you have an empty array. May be one of your arrays is empty, in other words your image may not have any pixels in one of the segments. Try reducing the number of segments to 3 or 2 depending on the number of features in your image.

    • @jubieralonsojimenezcamargo5732
      @jubieralonsojimenezcamargo5732 4 роки тому +4

      @@DigitalSreeni Same problem. The solution was by simply importing the image: as_gray = True . Thanks for your videos!!

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

    how can i solve this type of error
    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 607893 output values where the mask is true

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

    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 615204 output values where the mask is true
    ı got this error each time ı try to use the code, could someone help me?

    • @marioguzman9185
      @marioguzman9185 Місяць тому

      I also had this problem, it is solved by using the same image that they use in the video on GitHub you can find the image that is used, the link can be found in the description

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

    hi sir, thank for your video, but i cannot get the same results as and the following is the message: ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 39762 output values where the mask is true,how to deal with? sorry i'm not professional but i need solution

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

      Please check this, hopefully helps... stackoverflow.com/questions/26712044/valueerror-numpy-boolean-array-indexing-assignment-cannot-assign-0-input-values

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

    sir please explain the step in which u made np. zeros and . hsape[0] and .shape[1]

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

      Please read the comments in the code. In summary, you will be creating an array of the same size as the original image but with all zeros. You will then fill (replace) all zeros with values from segm1, segm2, etc. This is one way of combining your multiple segmented arrays into a single image.

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

    How can I count number of pixes of each segment?

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

      Please watch my videos numbered 32 to 35 on my channel. I also plan on recording another video soon on the topic of analysis.

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

    why we used cmap = 'gray' ? i didn't get it

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

      Because if you don’t define a color map to display your image Pyplot is going to display it using some default colors. This makes the image appear non-intuitive. By defining it as gray it makes the image easily interpretable.

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

    thanks for this great work. please can U put the link to download images You use in your demo. we want to execute the code with real images step by step

    • @DigitalSreeni
      @DigitalSreeni  5 років тому +3

      I just Google searched for 'SEM BSE image' and picked an image. Here is the direct link to the image I used in this tutorial - deben.co.uk/wp-content/uploads/2012/07/BS-Image-lrg.jpg

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

      or clone Sreenis github for all the files, highly recommended.

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

    Hii Sir , kindly tell where we find the code ?

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

      github.com/bnsreenu/python_for_microscopists

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

    Dear sreni sir please clear my query or I am not able to go ahead without

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

    plz make a video on temporal video segmentation

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

    please make video tutorial for segmentation by graph-based

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

      I will try but I am not a big fan of graph-cut based approach. It is an old approach and I prefer machine learning.

  • @prajwal6379
    @prajwal6379 9 місяців тому

    thank you

  • @김태호-m3d6l
    @김태호-m3d6l 3 роки тому

    thank you!

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

    all_segments[seg1]=(1,0,0)
    ValueError: NumPy boolean array indexing assignment cannot assign 3 input values to the 20727 output values where the mask is true
    i am getting this error sir. i am getting till the histogram part.
    please help

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

      sir my problem solved after reading the coments below