32 - Grain size analysis in Python using a microscope image

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • Understanding grains in metal alloys is important for quality control and research. Optical and electron microscopes are used to image well-polished alloy surfaces to capture grain structure. Automating the process of grain analysis not only speeds up QC/research but also yields consistent & repeatable results.
    This video tutorial explains the image processing tasks required to generate grain analysis summary and to capture it in a csv file.
    The code from this video is available at: github.com/bnsreenu/python_fo...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 80

  • @alkhashtee
    @alkhashtee 3 ปีที่แล้ว +8

    Man, I really appreciate and respect your way of explaining the theory part and the programming part of each step you do. Thank you very much.

  • @hamidcheraghi4114
    @hamidcheraghi4114 3 ปีที่แล้ว +2

    To be honest, I really like the way you teach. I learned a lot from your informative tutorials. Thanks

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

    I love your work sir. I graduated last year as a bio-technologist, but I loved image analysis. Now following your tutorial I'm going ahead!!

  • @debasishbarman96
    @debasishbarman96 4 ปีที่แล้ว +10

    This is the exact topic I have been searching for a long time

  • @leilakhalili9393
    @leilakhalili9393 2 ปีที่แล้ว

    Thank you very much for the video. I really enjoyed both of them(python command and concept).

  • @elifozkan9836
    @elifozkan9836 2 ปีที่แล้ว

    This tutorial was super helpful ! Thanks for a million times

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

    Thnak you very much for this video!
    it will help me with guidelines on how to automate image parameters analysis
    Also, my 13 yo cousin said he wanted to learn programim. I've done some reseatch into python and by god found your channel and gave it to him - his english is not good but he said he can learn A LOT from your videos!!!
    thank you for such high quality content!!!.

    • @DigitalSreeni
      @DigitalSreeni  4 ปีที่แล้ว +1

      My 12 year old son and his buddies have been learning python for the last couple of years. Your cousin is doing the right thing by learning to code, very important for his/her future. I believe you can turn subtitles on for my videos, hopefully that helps. Otherwise I hope you can find videos in your local language. My son started with this book a few years ago, books.google.com/books/about/Python_for_Kids.html?id=pMEUG8oNBfkC&printsec=frontcover&source=kp_read_button

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

      @@DigitalSreeni thank you very much!!!!!

  • @patrickwl6019
    @patrickwl6019 11 หลายเดือนก่อน

    Amazing idea, looking forward to recreate similar code for blasting fragmentation👌

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

    I just want to say thank you for making these videos. They are fantastic and are really helping with my own research .

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

      Glad to hear that you find them useful.

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

    Thank you very much for your videos! These are very very helpful!

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

    Hello Dr., thank you for this video. Could you please reply whether some functions exist for 3D grain analysis?

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

    Hello Sir, thank you so much for your video tutorial! It was really helpful. Is there a way to get the coordinates of each particle that we find? Thanks once again

  • @hammao
    @hammao 2 ปีที่แล้ว

    I want to personally thank you for this wonderful videos... This exactly what I need to up my python and image analysis game. Besides, you side comments makes the whole exercise humanly !!! for example, I can easily relate to looking and typing 😂😂😂
    I have two questions
    1. for the grain size analysis, do you mind using actual geological samples ( I have many I can share), the sample you're using to demonstrate is to easy to use but geological or soil samples can be very more complex to work with.
    2. I started following the videos you recorded for Apeer, then I stumbled on this set of videos (microscopy series), which seems to directly talk to me 😅😂😂😂😂. Which playlist do you recommend among the two? My aim is to gain mastery in image analysis of geological samples.

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

    Fantastic work, thank you very very much for what you are doing. I like when you're cheating... good job, hope you continue to make such excellent videos.

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

      This is brilliant, thank you so much

  • @paul-tiberiumiclea1429
    @paul-tiberiumiclea1429 2 ปีที่แล้ว

    Dear Sreeni, very nice tutorial. I have a question. In imageJ (or pevious versions) it is possible to show the grains as countour and also the label inside. In the tutorial you show hou tho see the label_marks as colors. There is any chanse to show them as contur? I try using skimage.contour but then the numbe of contours and the number of label_mask is different. Thanks

  • @felipemondaca5106
    @felipemondaca5106 3 ปีที่แล้ว +3

    ​ @DigitalSreeni Hi. Thanks for your video. I have the same question that DJ Deka. Why are you using 0.5 um? I know that 1px = 264.58 um. I am using an image SEM with your python code to calculate particle size. My image has a magnification of x50,000 and its scale bar is 100 nm. Is 0.5 um right for my case? Thanks.

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

    this video was really one of your best uploads Sreeni!
    great content
    did you manage to make that video with cell images that you mentioned at around 39:55?

  • @raviperi6908
    @raviperi6908 6 หลายเดือนก่อน

    Quite helpful and informative, training me well..@digitalsreeni your intent is well received..thank you and please keep doing these..

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

    Great job srini.

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

    Thank you very much for your video. I wonder if we can write the label_name ( in column 1 of the csv file) to the original image? I want to know which label related to which position in the image!

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

      You can report label and also coordinates for the label. Please check the documentation for regionprops to see all the parameters that you can report.
      scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops

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

    Sir, thank you for clear explanation. But I need to ask for plt.hist command if my image was 24 or 36 bit

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

    Hi Sreeni,
    Thank you for the video. You have well explained every steps.
    I am analysing an image of fiber reinforced composite transverse section. I have to find out the coordinate of center of fiber (approx. circular) and diameter. I see you used equivalent diameter which I can use for diameter. But I don't know what to use to extract coordinate of each fiber center. For simplicity, its equivalent in your analysis would be to find centre of each grain assuming each grain as circular.

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

      Please watch my video 116 to understand how to get properties of segmented / labelled regions. The output provides you with a lot of measurements including centroid. Here is the link to regionprop documentation.
      scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops

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

    sir, thanks a lot for the explanation. Could you explain what does the intensity in skimage measure means? does higher value means brighter or darker regions?

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

      Intensity is basically pixel values for that specific object in your original image. Yes, it means brighter and darker in your original image.

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

    sir,pls upload the video of analysis of segmented part after u-net segmentation

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

    Very informative and brilliant...Can you please record another video on stereology which helps obtain 3D grain size distribution from 2D images?

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Not an easy topic to cover in a video, unless a library already exists. I will see if I can find a library on this topic.

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

    Excellent

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

    hello I have a question for the output you generate what is the grain size in nm² and how much grains do i have in my image, it might be depends on the scale of the image which are you took with the microscope but how can I measure that? thank you very much

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

      In the code I converted pixels to microns based on the scaling factor. If you want square nanometers instead of square microns then just multiply sq. microns by 1 million (10^6). I hope this answers the question. In fact, if you want to convert any units the best online resource is Wolfram Alfa. Here is the link where you can see um2 converted to nm2. www.wolframalpha.com/input/?i=1+um2+to+nm2

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

    Great Video. One question. What is the the major and minor axis measuring unit - Pixels or micron?

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

      It calculates pixels by default, we convert it to microns by multiplying the output with the scaling factor (pixel_to_um).

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

      @@DigitalSreeni thank you for your reply. Is 1 pixel=0.5 microns a standard?

  • @milindvadagave
    @milindvadagave 2 ปีที่แล้ว

    cannot import name 'check_nD' from partially initialized module 'skimage._shared.utils' (most likely due to a circular import) facing this in spyder. plz help

  • @homerianreyes8688
    @homerianreyes8688 2 ปีที่แล้ว

    Great very well taught and I learn a lot. Just want to know if this is applicable on normal grain images? which is not microscopic image. Thank you for the response.

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

      This is a generic approach that should work with any image, provided you pay attention to each step and define parameters accordingly.

    • @homerianreyes8688
      @homerianreyes8688 2 ปีที่แล้ว

      @@DigitalSreeni oh thank you! actually I'm trying to segment multiple grains in an image and save is as a separate images, is there any video you recommend in your playlist that I can learn concerning this topic?

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

    from skimage import measure, color, io, can I use them with cv2 instead of skimage?? If I can, please, help.

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

      I don't understand your question. You can use skimage or opencv if an equivalent function exists. A quick Google search can tell you whether the function exists in a given library.

  • @aleenab2002
    @aleenab2002 2 หลายเดือนก่อน

    Which version of python is this?

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

    Hello, can we same program to identify orientation of fibers in microscope image?

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

      This approach doesn't care about the application, as long as the fibers are segmentable.

  • @srikrishnarkapillalamarri3496
    @srikrishnarkapillalamarri3496 3 ปีที่แล้ว +1

    Hello Sir, thank you very much for this detailed explanation. I evaluated the feret diameter of microscopic particles using ImageJ. I would like automate the entire process using Python. I have tried the code which you have explained, but not able to measure the dimensions of the mask. P,lease suggest

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Please watch my video 116.

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

      @@DigitalSreeni sir, thank you very much, this will help me greatly in automating my feret diameter measurements for ~500 images

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

    One question regarding the image reading. I tested plt.hist() using skimage and cv2. When showing the image, is the same, but when plotting the data in histogram, it shows different data. Any idea why? They are both as gray.

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      I believe skimage uses 64 bit float while reading images whereas opencv uses ubyte (unsigned integer). Try converting skimage imported image to ubyte and then looking at histogram. Hopefully it matches with the opencv histogram.
      from skimage import img_as_ubyte, io
      img = io.imread("your_image")
      img_as_ubyte = img_as_ubyte(img)

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

      @@DigitalSreeni That works perfectly well. Thank you for the response.

  • @srikrishnarkapillalamarri3496
    @srikrishnarkapillalamarri3496 3 ปีที่แล้ว +1

    Hello sir, could you make introduction video about particle tracking (trackpy) using particle flow videos, I could not find am forum where I could request you about this. Thank you,

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +2

      I will add them to my list. Thanks for the suggestion.

  • @nairsrijith8553
    @nairsrijith8553 2 ปีที่แล้ว

    Can you please help me to get Voronoi tessellation diagram of PDLC material plzzz sir

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

    Sir, learning a lot from your video. Great Help!! One request, could you create one video for microalloyed steel/(cementite in tempered martensite matrix) with grain analysis (Feret diameter, FeretX and FeretY)?

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

      Can you please share an image?

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

      @@DigitalSreeni I have mailed the image to you. Looking forward to your video..

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

    image_measurements.csv initially gave me a blank table, no values nor header in it (even though the script ran without error).
    It took a little while to realize that my mistake was to still have at the bottom of the python file:
    cv2.imshow('eroded', eroded)
    cv2.waitKey(0)
    Leaving out these two lines produced the desired result.. a filled table (columns Area...MaxIntensity and rows 1..N for each detected cluster)

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

      Those 2 lines are just displaying your image on the screen, the code will not move unless you close the opened window. You can set a wait time under waitKey(0); instead of 0 which means you have to close the window manually you can set a value, e.g. 5000 (5 seconds).

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

    How you knew at the beginning that the scaling factor pixels_to_um = 0.5 ?

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

      This is a number you get from your imaging device - basically pixel size that gets captured or you need to define based on the scalebar.

  • @shuvamgupta2236
    @shuvamgupta2236 2 ปีที่แล้ว

    Hi sir how to measure volume of particles in 3d images? Please let us know.

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

      Once you segment them into individual objects, you just look at total number of pixels (voxels) to find the volume. If you know the pixel size, you can convert pixel volume to real units (e.g., um3).

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

    Do you have a Patreon account where I could contribute?

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

      Thanks for asking. Yes, I do have a Patreon page where I collect proceeds for charity. If you'd like to contribute here is my Patreon page: www.patreon.com/bnsreenu

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

    in what unit the area and perimeter are?

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว +1

      Unless you multiply them with scaling factor the units will be in pixels and square pixels. Multiply them by pixel size to convert to physical units.

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

    I am pursuing a project to Encode microstructure using python, can you upload video or share some relevant information for the topic as it is very difficult to find.

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

      I don't know what you mean by 'encode microstructure', can you please elaborate?

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

      @@DigitalSreeni i.e digitaly representing microstructure from an given image

  • @jimquinn
    @jimquinn 5 ปีที่แล้ว +1

    Thank you. Liked. Subscribed. Please google : Mike Meier Artificial Microstructure.
    His PDF article on creating images for ASTM grain sizeing is neoclassic.