26 - Denoising and edge detection using opencv in Python

DigitalSreeni
20 May 201920:58

Summary

TLDRIn this Python tutorial, Trini from the 'Python for Microscopists' YouTube channel explores OpenCV's image processing capabilities, focusing on denoising and edge detection. She demonstrates various blurring techniques like averaging, Gaussian blur, and custom filters, emphasizing the importance of kernel size. Trini also introduces edge detection using the Canny algorithm, showcasing its effectiveness in identifying image edges. The tutorial is aimed at those interested in pre-processing microscope images for tasks like segmentation and object detection.

Takeaways

  • 😀 The tutorial focuses on OpenCV, a library used for machine vision and image processing, including microscope images.
  • 🔍 Denoising and blurring are discussed as important pre-processing steps for image segmentation.
  • 💻 The IDE used is part of the Anaconda distribution, and OpenCV, NumPy, and Matplotlib are the primary libraries imported.
  • 📸 The image 'BSC_Google_9e.jpg' is used as an example, which is a microscope image with added noise.
  • 🛠️ Denoising methods include averaging, Gaussian blur, and median filtering, which are performed by convolving an image with a kernel.
  • 📊 A custom 5x5 kernel is created using NumPy, normalized to maintain the original image's energy.
  • 🔧 The cv2.filter2D function is used for custom filtering, and cv2.blur and cv2.GaussianBlur are used for built-in blurring techniques.
  • 📈 The tutorial compares different denoising methods, highlighting the effectiveness of Gaussian blur and median filtering in retaining edges.
  • 👁️‍🗨️ Bilateral filtering is introduced as a favorite method for noise removal while preserving edges, which is crucial for microscope images.
  • 🏞️ Edge detection is covered, with a focus on the Canny edge detection method, which is useful for identifying significant transitions in images.

Q & A

  • What are the two main topics discussed in the Python tutorial video by Trini?

    -The two main topics discussed are denoising or blurring and edge detection, which are important pre-processing operations for image segmentation.

  • Why is OpenCV used in the tutorial?

    -OpenCV is used because it is a library primarily dedicated to machine vision applications and has very good tools for image processing, including microscope images.

  • What is the purpose of importing NumPy in the context of this tutorial?

    -NumPy is imported for array manipulations, specifically to generate a matrix for defining a kernel used in the denoising process.

  • How does the denoising process work in the tutorial?

    -Denoising involves manipulating the image using a kernel to reduce noise. This can be done through averaging, Gaussian blur, or other filtering techniques like median or bilateral filtering.

  • What is the significance of normalizing the kernel by dividing it by 25 in the tutorial?

    -Normalizing the kernel by dividing it by 25 ensures that the total energy of the image is not altered during the convolution process, maintaining the original image's characteristics.

  • Why is a 5x5 kernel used in the denoising example?

    -A 5x5 kernel is used to apply a larger area of averaging, which can be more effective in reducing noise while preserving image details compared to smaller kernels.

  • What is the difference between the custom filter and the Gaussian blur in the tutorial?

    -The custom filter uses a simple averaging method with an all-ones kernel, while Gaussian blur uses a kernel with values that decrease based on the distance from the center, emulating a bell curve.

  • How does the median filter help in retaining edges during denoising?

    -The median filter retains edges by replacing the central pixel value with the median of the pixel values in the kernel, which is effective in removing noise while preserving edges.

  • What is the bilateral filter and why is it one of Trini's favorite filters?

    -The bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter. It is favored because it effectively removes noise while keeping edges sharp, which is crucial for image processing tasks like image segmentation.

  • What is the Canny edge detection method and how is it used in the tutorial?

    -The Canny edge detection method is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. In the tutorial, it is used to highlight the edges of a neuron in a microscope image.

  • What are the next steps in image processing after denoising and edge detection as suggested by Trini?

    -After denoising and edge detection, the next steps suggested are image thresholding and segmentation, which are further pre-processing operations leading to more advanced image analysis.

Outlines

00:00

💻 Introduction to OpenCV for Image Processing

In this tutorial, Trini introduces the audience to OpenCV, a library primarily used for machine vision applications but also equipped with robust tools for image processing, including microscope images. The focus of the lecture is on two essential pre-processing operations: denoising/blurring and edge detection, which are crucial for tasks like image segmentation. Trini demonstrates how to import OpenCV and other necessary libraries such as numpy and matplotlib within the Python environment, specifically using the IDE provided by the Anaconda distribution. The video aims to guide viewers through the process of reading and manipulating images using these libraries.

05:02

🔍 Exploring Denoising Techniques in OpenCV

Trini delves into the topic of denoising, explaining the process of reducing noise in images through techniques like averaging, Gaussian blur, and median filtering. The tutorial demonstrates how to create a custom filter using a kernel, which is a matrix used for convolution operations. The video shows how to define a 5x5 kernel using numpy, normalize it, and apply it to an image using OpenCV's filter2D function. Trini also compares the results of using this custom filter to the built-in blur function in OpenCV, highlighting the subtle differences and the importance of kernel size in the denoising process.

10:03

📊 Comparing Different Blurring and Denoising Filters

The video continues with an exploration of various blurring and denoising filters available in OpenCV. Trini compares the effects of using a regular blur, Gaussian blur, and median blur on an image. Each filter is applied to the same image, and the results are displayed side by side to illustrate the differences. Gaussian blur is highlighted for its effectiveness in denoising while preserving edges, and median blur is noted for its ability to retain edges more effectively than Gaussian blur. The tutorial also briefly mentions bilateral filtering and non-local means filtering as additional methods for denoising that are particularly useful for preserving texture in images.

15:04

🧠 Edge Detection Techniques in Image Processing

Moving on to edge detection, Trini demonstrates the use of the Canny edge detection algorithm in OpenCV. The video shows how to read a microscope image of a neuron and apply the Canny function to detect edges. The parameters for the Canny function are discussed, and the results are presented, showing how the algorithm effectively identifies the neuron's edges and the synapses. The tutorial emphasizes the importance of choosing the right pre-processing operations based on the type of image and the information that needs to be extracted.

20:04

🔄 Wrapping Up and Looking Forward to Further Processing

In the final part of the tutorial, Trini summarizes the pre-processing operations covered, including denoising, blurring, and edge detection, and their relevance to further image processing tasks such as segmentation and object detection. The video concludes with a reminder to the audience to subscribe to the channel for more educational content on Python and image processing. Trini expresses gratitude for the viewers' engagement and motivation to continue creating informative videos.

Mindmap

Keywords

💡OpenCV

OpenCV, which stands for Open Source Computer Vision Library, is a highly popular library used for computer vision and image processing. In the video, OpenCV is the primary tool used to demonstrate various image processing techniques. It's mentioned as having 'very good tools for image processing,' which includes functionalities for microscope images. The script shows how to import OpenCV in Python and use it to perform operations like denoising and edge detection.

💡Denoising

Denoising is the process of reducing noise in images, which can be caused by various factors such as sensor noise or compression artifacts. In the context of the video, denoising is one of the two main topics discussed. The script explains how denoising can be achieved through different methods like averaging, Gaussian blur, and median filtering. Denoising is crucial for improving image quality before further processing.

💡Blurring

Blurring is a technique used to reduce image sharpness, often as a pre-processing step to smooth out images or to remove noise. The video script discusses blurring in the context of denoising, mentioning that blurring can be achieved through methods like applying a kernel to an image. The script demonstrates how blurring can be done using OpenCV functions such as `cv2.blur` and `cv2.GaussianBlur`.

💡Edge Detection

Edge detection is a key concept in image processing that involves identifying and highlighting the boundaries of objects within an image. In the video, edge detection is the second main topic and is demonstrated using the Canny edge detection method. The script shows how edge detection can be performed using OpenCV's `cv2.Canny` function, which is useful for identifying features like the neuron and its synapses in a microscope image.

💡Kernel

In the context of image processing, a kernel is a small matrix used for various operations such as blurring and edge detection. The script explains how a kernel can be defined using numpy arrays and how it is used in convolution operations to apply filters to images. The kernel's size and values significantly affect the outcome of the image processing, as demonstrated by the different blurring effects when using different kernel sizes.

💡Convolution

Convolution is a mathematical operation used in image processing to apply a filter to an image. The video script describes convolution as the process of 'multiplying' a kernel by progressively moving it across the image. This operation is fundamental in applying filters for denoising and blurring, as well as in edge detection. The script demonstrates how convolution is performed using the `cv2.filter2D` function in OpenCV.

💡Numpy

Numpy is a Python library used for numerical operations on arrays. In the video, Numpy is imported to create and manipulate arrays, which are essential for defining kernels and performing operations like convolution. The script shows how Numpy is used to create a 5x5 array of ones to define a kernel for blurring, highlighting its importance in image processing tasks.

💡Matplotlib

Matplotlib is a plotting library in Python that is used for creating static, interactive, and animated visualizations. Although the video primarily focuses on using OpenCV for image display, Matplotlib is mentioned as a tool that might be used for plotting histograms or other visualizations. The script includes an import statement for Matplotlib's `plt` to potentially use it for such purposes.

💡Gaussian Blur

Gaussian Blur is a technique used to reduce image noise and detail by applying a Gaussian function, which resembles a bell curve, to the image. The video script explains Gaussian Blur as a method for denoising that uses a kernel with values that decrease as they move away from the center. The script demonstrates how Gaussian Blur is performed using OpenCV's `cv2.GaussianBlur` function, which is effective in preserving edges while reducing noise.

💡Median Filter

The Median Filter is a non-linear digital filtering technique often used to remove noise from an image while preserving edges. The video script describes the Median Filter as a method that retains edges better than Gaussian Blur. It is performed using the `cv2.medianBlur` function in OpenCV. The script shows that the Median Filter can be effective in reducing noise, especially in images where edge preservation is critical.

💡Bilateral Filter

The Bilateral Filter is an edge-preserving smoothing filter used in image processing. Unlike the Median Filter, the Bilateral Filter considers the intensity of the pixels while filtering, which helps in retaining edges more effectively. The video script introduces the Bilateral Filter as one of the favorite filters of the presenter for noise removal while keeping edges sharp. The script demonstrates the use of the `cv2.bilateralFilter` function in OpenCV.

Highlights

Introduction to OpenCV, a library for machine vision and image processing.

Focus on denoising or blurring and edge detection as important pre-processing operations for image segmentation.

Importing necessary libraries: OpenCV, numpy, and matplotlib for image manipulation and plotting.

Reading an image with noise to demonstrate denoising techniques.

Explanation of denoising methods including averaging, Gaussian blur, and median filtering.

Creating a custom kernel for denoising using numpy and applying it with cv2.filter2D.

Demonstration of the effect of different kernel sizes on the denoising process.

Comparison between custom filter and OpenCV's built-in blur function.

Introduction to Gaussian blur and its implementation in OpenCV.

Comparison of linear and nonlinear filtering methods, including median and bilateral filters.

Discussion on the importance of retaining edges in denoising, especially for microscope images.

Practical demonstration of median and bilateral filters on a noisy image.

Introduction to edge detection and its significance in image processing.

Explanation and application of the Canny edge detection algorithm in OpenCV.

Demonstration of edge detection on a microscope image of a neuron.

Highlighting the importance of choosing the right pre-processing operations for specific types of images.

Conclusion and预告 of upcoming tutorials on image thresholding and segmentation.

Call to action for viewers to subscribe for more Python image processing tutorials.

Transcripts

play00:00

hey guys this is Trini and you're

play00:02

watching Python tutorial videos on my

play00:04

channel Python for microscopists on

play00:06

YouTube in today's tutorial let's

play00:09

continue talking about open CV which is

play00:11

the library primarily dedicated to

play00:15

machine vision type of applications but

play00:18

has very good tools for image processing

play00:21

even microscope images or even

play00:23

microscope images so in today's lecture

play00:26

let's just focus on two topics one is

play00:29

denoising or blurring and the other one

play00:33

is edge detection again a couple of very

play00:36

important pre-processing operations that

play00:39

you may need to perform if you are

play00:41

interested in image segmentation for

play00:44

example so let's go ahead and jump into

play00:48

spider which is again the IDE that's

play00:50

part of anaconda distribution now to

play00:54

import OpenCV just to remind everyone

play00:57

import cv2 and typically there are three

play01:02

things that I kind of import by default

play01:05

and let's go ahead and do that open CV

play01:08

numpy because you never know when you

play01:11

need to do some sort of a array

play01:13

manipulations no array map so we're

play01:18

doing CV two and numpy and other one is

play01:21

matplotlib even though I plan on

play01:24

actually using open CV to show images I

play01:29

may have to plot the histogram for

play01:32

example and for that pie plot is pretty

play01:34

pretty useful so let me go ahead and do

play01:37

that from matplotlib import I plot as

play01:42

PLT okay so these are the libraries that

play01:46

we want and now let's go ahead and read

play01:48

our image so the first topic is

play01:52

denoising so let's import an image that

play01:55

actually got some noise I've Google

play01:58

searched for an image and

play02:01

just added some random noise to it so

play02:03

let's go ahead and use that image and

play02:05

this is CB 2 dot M Reid and it's in

play02:08

images and it's called Google no I think

play02:14

it's called BSC I can actually go to my

play02:17

file explorer look at images and this is

play02:20

BSC underscore or Google and underscore

play02:23

9e Google I see dot jpg and let's go

play02:34

ahead and read it in color again the way

play02:36

we do that is one zero means if we are

play02:39

reading the image as a gray level image

play02:42

this is I believe a gray level image to

play02:44

begin with so let's let's know how to

play02:46

read it as as one now one of the first

play02:51

let me take a step back like whenever we

play02:54

do be noising we are manipulating the

play02:58

image somehow and how do we do denoising

play03:01

I mean we can either do averaging you

play03:04

know average of a few pixels that kind

play03:06

of minimizes the noise you can do

play03:08

Gaussian blur in like apply a Gaussian

play03:10

filter and then blur it you can do like

play03:12

for example a filter called median

play03:15

whatever process you follow all we are

play03:19

doing is you take a kernel the kernel

play03:23

can be a three by three matrix for

play03:25

example it can be a five by five matrix

play03:27

whatever it is you take a kernel and you

play03:31

convolve it meaning you kind of multiply

play03:34

it you know by progressively moving it

play03:37

on your image your image is nothing but

play03:40

a very big matrix or a very big array or

play03:42

kernel is a smaller array that we are

play03:44

stepping through the image so that we

play03:48

can actually define this kernel if you

play03:50

import or if we use a predefined process

play03:56

you know within OpenCV or whatever

play03:58

psychic image it comes with a predefined

play04:01

kernel but we can define our own and

play04:03

that method within OpenCV is done via CV

play04:08

2 dot filter to D so it's CV 2 dot

play04:13

filter and to be I believe is uppercase

play04:17

okay we'll figure this out in a second

play04:19

so this is what we need but the

play04:21

arguments here is the first one is an

play04:25

image but then we need to define a a

play04:27

kernel okay so the first one is image

play04:30

and then let's let's get to this in a

play04:33

second so how do we define our kernel

play04:36

well this is nothing but this is the

play04:39

reason why I imported numpy because we

play04:41

know how to generate a a matrix of all

play04:45

ones okay so this is done by NP dot once

play04:48

and let's just do 5x5 array and then I'm

play04:56

gonna convert this this this needs to be

play04:58

I want this to be a float32 type okay

play05:01

and P dot float32

play05:03

and the reason why I want this as a

play05:05

float32 and not an integer is we are

play05:08

doing some max to the image so we want

play05:10

these to be float and more importantly

play05:12

the reason I want it to be is because

play05:14

I'm dividing this by 25 5x5 of all ones

play05:18

means I have 25 ones in my matrix I am

play05:25

normalizing this by dividing it by 25 so

play05:28

all the elements within the matrix add

play05:30

up to one okay

play05:32

you do not want to change the energy of

play05:35

your image of your original image so by

play05:38

multiplying it by one we are not

play05:39

altering the total energy contained

play05:41

within this image that's the reason why

play05:43

I'm normalizing it by 25 here if this is

play05:46

a three by three matrix I would divide

play05:47

this by nine okay so this is our kernel

play05:52

and we are all set actually so let's

play05:55

actually define let's go ahead and use

play05:59

this okay let me give a little bit of

play06:04

room there so we have our image we have

play06:07

our kernel so let's just call this our

play06:09

filter okay

play06:10

our filter I think filter is a built-in

play06:14

term so let's just use filt underscore

play06:16

to be okay so my 2d filter is nothing

play06:20

but C v2 dot filter 2d and I have my

play06:23

image and

play06:25

we can look up at the documentation

play06:27

actually but I need to define my kernel

play06:30

right there okay and this is nothing but

play06:34

convolution using the kernel that we

play06:37

have just defined okay let's go ahead

play06:40

and look at the image CV to dot M shell

play06:43

and we know how to look at this and I'm

play06:45

going to call this let's actually put

play06:47

both original image and originally image

play06:53

is IMG and CV two dots

play06:56

I'm sure and let's call this 2d custom

play07:02

okay and this is fil t 2d and every time

play07:09

you use cv 2 dot M shell again see v2

play07:12

dot weight uppercase K okay weight key

play07:17

and how long do we want to wait until we

play07:19

provide until we provide a figure you

play07:22

know until we close it see v2 dot dish

play07:29

okay so let's go ahead and run this and

play07:35

you see the original image here which is

play07:38

noisy and you see the blurred image or D

play07:43

noise to image it's actually not bad

play07:44

it's D noise except we act let's go

play07:48

ahead and close this except we are you

play07:52

know convolving it with a filter of five

play07:54

by five let's go ahead and do three by

play07:56

three and nine okay that's fungus and

play08:00

see how the extent of blurring actually

play08:03

this is not bad

play08:04

it did D noise a little bit but it also

play08:07

did not blur the image a lot okay so

play08:10

three by three seems to work very well

play08:12

on this specific image let's leave our

play08:16

kernel size to three by three for now

play08:18

and I'm going to show you a few other

play08:22

types of filters another type of filter

play08:26

that we have is blur so see let's call

play08:29

this or equal to it's nothing but C v2

play08:33

dot blur that's it and then we need to

play08:36

just give our image

play08:38

and our input image is called image and

play08:41

then now we need to give what the what

play08:44

the kernel size is you know for this

play08:46

image and I'm cheating here a bit on the

play08:49

other side I have the documentation for

play08:51

all of this so I need to so I can I can

play08:54

make sure you know I do this video in a

play08:57

smooth way otherwise I'll make a bunch

play08:59

of mistakes go back and correct them

play09:00

okay so you can also go ahead and cheat

play09:03

nothing wrong with that as long as you

play09:05

cut down your execution time you know

play09:07

this is it's a good way of learning so

play09:10

this is a built-in function so let's go

play09:13

ahead and let's go ahead and try to see

play09:20

this image blur and let's run this

play09:27

so this is our blurred image which also

play09:30

is denoise this is our original image

play09:33

and let me move this to this side and

play09:35

this is the one on the right hand side I

play09:38

have my custom filtered image and on the

play09:40

left hand side this is a blurred image

play09:42

although I should go back and see what

play09:44

did I use for my blur it's not fair to

play09:47

compare five by five yeah let's go to

play09:50

three by three okay because I was

play09:52

expecting not much difference between

play09:54

these two because blur is nothing but

play09:57

exactly the CV to dot collector to D

play09:59

yeah this is nothing but that except

play10:02

here we are defining the kernel size the

play10:04

kernel size is three by three and it's

play10:06

it's defining the kernel here I define

play10:09

the kernel and I just gave that kernel

play10:11

as an input here so let's do this one

play10:14

more time and I should yeah on the left

play10:17

hand side I have blur on the right hand

play10:19

side I have custom filter they almost

play10:22

look exactly the same okay so but the

play10:25

good thing with custom filter is now I

play10:27

don't have to I mean using all ones is

play10:29

the easiest way of doing it but then you

play10:32

can define a Gaussian kernel you can

play10:34

define your own lawrencium type of

play10:36

kernel if you are good at defining your

play10:38

kernels then you can define whatever and

play10:40

then actually get the best out of this

play10:42

so that's why see v2 dot filter 2d

play10:46

exists in addition to this we also have

play10:48

a Gaussian blur

play10:52

as the name suggests this is nothing but

play10:54

instead of all once in the kernel it

play10:57

uses a gaussian macaw sein is nothing

play10:59

but a bell curve you know when you do a

play11:02

distribution of random numbers for

play11:04

example you end up with this normal

play11:06

distribution right so it's almost a

play11:07

Gaussian it's not exactly at all so it's

play11:09

almost a Gaussian so instead of one

play11:12

dimension if you do that in 2d the

play11:14

Gaussian looks like a mountain okay no

play11:17

so that's what Gaussian blur actually

play11:20

does the central values are larger and

play11:23

the values taper off as you go away from

play11:26

the center but when you add all the

play11:28

numbers they should add up to one again

play11:30

and by doing Gaussian blur it does take

play11:33

care of this so see v2 dot D you know I

play11:37

think it's uppercase again that's why

play11:39

I'm cheating here because I do not want

play11:41

to make these little mistakes Gaussian

play11:43

blur and the way we do here is obviously

play11:48

what are we blurring we are blurring our

play11:50

image yeah by how much are we learning I

play11:54

and also zero and you can actually go

play11:58

ahead and look at documentation what

play11:59

zero means so what is it saying

play12:04

I'm defined Gaussian okay that's fine oh

play12:06

sorry equal to okay

play12:10

so let's also add Gaussian blur down

play12:13

here so we can actually look at what it

play12:16

is how it looks like we call this and

play12:23

before looking at this image let's also

play12:25

well actually let's let me also define

play12:29

one more now all up until this point you

play12:32

know Gaussian blur and everything I

play12:34

believe even Gaussian is called a linear

play12:37

convolution you know process now there

play12:41

is a nonlinear process so and usually

play12:44

these non linear ones retain edges so

play12:47

one of those is median the other one is

play12:50

called bilateral so let's look at median

play12:52

and bilateral in a minute but let's run

play12:54

these so you can see how Gaussian looks

play12:56

like there you go this is a regular blur

play13:00

we looked at that and this is our

play13:01

Gaussian blur

play13:02

much better than these other ones

play13:05

but they all look pretty much the same

play13:07

you know again now which kernel did I

play13:10

use for Gaussian again five by five if I

play13:13

actually do three by three it probably

play13:15

looks better than the other two so let's

play13:18

go ahead and run this one more time so

play13:20

this is my Gaussian blur and this is my

play13:22

2d custom filter just have to tell the

play13:24

difference you know

play13:25

although Gaussian looks slightly better

play13:29

to me when it comes to edges so let's

play13:33

see if our median filter has any better

play13:37

job than gaussian median is a good

play13:40

option if you want to do if you want to

play13:43

retain edges so that I already mentioned

play13:46

that so this is called CV 2 dot again

play13:50

let me go ahead and cheat median blur

play13:55

okay median upper case B okay and we are

play14:02

doing that on our image and our kernel

play14:04

size let's actually keep it three you

play14:06

just need to say three you don't need to

play14:08

do three by three so let's go ahead and

play14:12

also look at this median we call it

play14:16

median blur I like to call this median

play14:18

filter because we are filtering in a way

play14:20

the image so let's just call this median

play14:25

underscore blur let's go ahead and print

play14:28

all of these are show all these images

play14:30

and median showed up here and let's go

play14:33

ahead and compare median and Gaussian I

play14:35

don't know if you can tell from the

play14:37

video but Gaussian seems to be a bit

play14:39

more blurred than median you see median

play14:42

retained all the edges they all I mean

play14:46

this is the original image by the way

play14:47

it'll compare original and million

play14:49

that's not bad I mean the edges are

play14:51

sharp here they're just a relatively

play14:53

sharp over there and most of the noise

play14:55

seems to be gone okay so let's stop

play15:00

showing other images right now so let's

play15:04

actually delete the 2d custom blur and

play15:07

also Gaussian blur we understand what

play15:10

they do let me go ahead and add one more

play15:15

one of my favorite filters

play15:18

bilateral learn I said one of my

play15:23

favorite because this is very good for a

play15:27

noise removal and retain the edges even

play15:30

better than medium blur let's hope to

play15:32

see see that here CV - and what do we

play15:36

called by later oh I think F is again I

play15:40

do not have that here so what do I do

play15:45

let's go ahead and do image and again

play15:48

for to understand the parameters you can

play15:50

actually go and you know search online

play15:53

for what the input parameters actually

play15:55

mean this is typically the kernel size

play15:57

this can be the patch size you know how

play15:59

fast you want to move on the images so

play16:01

each filter has its own way of dealing

play16:04

with the kernel and the parameters

play16:08

basically are one way of I mean the way

play16:11

you're telling exactly how you want the

play16:13

filtering to be done so let's call this

play16:16

bilateral and this is bilateral

play16:18

underscore blur I think we got

play16:22

everything okay let's go ahead and run

play16:24

this and here is the bilateral and

play16:27

original image the noise is not that

play16:30

much cleaned as you see compared to the

play16:32

original maybe we can play with the

play16:34

parameters and see but the edges are

play16:36

much sharper compared to the medium

play16:38

filter one thing I'm not gonna show

play16:42

right now is something called non-local

play16:45

means filter I in fact I didn't even

play16:48

know I've never looked up for a

play16:51

non-local means filter on open CV I know

play16:55

it actually exists in psychic image so I

play16:58

keep using the one from psychic image

play17:00

and I have covered that in one of my

play17:03

previous videos anyway so I'm not going

play17:05

to cover that in this specific tutorial

play17:08

but again the name is non-local means

play17:11

filter okay NLM does an amazing job

play17:15

filtering microscope images denoising

play17:17

microscope images and yet retaining the

play17:20

texture because texture is very

play17:22

important in microscope images no need

play17:24

to mention that okay so these are

play17:27

various denoising or blurring

play17:30

you know functions now let's actually

play17:33

look at an edge detection and edge

play17:37

detection function so in fact let's only

play17:40

look at again there are a lot of

play17:42

different choices if you look at psychic

play17:44

image which I already covered anyway so

play17:47

I'm going to just show you one of the

play17:49

ones that I probably did not cover

play17:51

inside get image which is canny edge

play17:53

detection okay so let's go ahead and

play17:56

read the image and I'm also going to

play17:58

leave these print or in show statements

play18:02

right there so let's read a because we

play18:08

are going to do edge detection let's go

play18:11

ahead and look at an image called neuron

play18:13

okay and then zero and let's go ahead

play18:19

and show original image first so you

play18:21

know exactly what I'm talking about okay

play18:24

this is nothing but our image so let's

play18:28

show the original image and this is what

play18:31

I'm talking about this obviously a

play18:33

microscope image and it's a neuron and a

play18:36

whole bunch of lines or you know if

play18:39

you're a biologist you know the

play18:40

technical term synapses I guess you know

play18:43

our axons I don't know the difference

play18:45

but anyway the a bunch of lines you know

play18:49

from image processing point of view

play18:50

streaks going from this neuron so let's

play18:54

just do let's just do edge detection so

play18:58

it's nothing but edges equals C v2 dot

play19:03

uppercase C canny and what do we want to

play19:09

do our image and again you can look up

play19:11

the parameters but if this is nothing

play19:15

but the minimum value for canny is 100

play19:17

the maximum is 200 so let's see how that

play19:20

image looks like you can play with that

play19:21

this is nothing but your minimum and

play19:23

maximum values okay and now let's just

play19:26

show our canny this is it

play19:31

just one line and that does the edge

play19:33

detection and it looks exactly like

play19:38

original image that is because I'm

play19:40

looking at

play19:43

okay so let's look at edges and now

play19:46

there you go so it kind of detected this

play19:49

hard edges where the transition takes

play19:51

place in this case we have the neuron

play19:54

right there and then there is a very big

play19:56

change in gray level from the from this

play20:00

from this neuron you know to the

play20:04

surrounding to the background so this is

play20:06

one way again when do you use this it

play20:10

completely depends on your type of image

play20:12

and what the information you are trying

play20:14

to extract out of this image so these

play20:17

are again a couple of pre-processing

play20:21

operations that you could do again

play20:24

leading up to image segmentation or

play20:26

object detection whatever you want to do

play20:28

you know further image processing let's

play20:30

extend this let's look at a couple more

play20:33

in a pre-processing operations in our

play20:36

next video and possibly get into image

play20:38

thresholding and maybe segmentation

play20:41

thank you very much for watching this

play20:43

video again please do not forget to

play20:44

subscribe to this channel which keeps me

play20:47

motivated to make more such videos and

play20:50

and and teach you guys you know whatever

play20:53

I know when it comes to Python image

play20:56

processing thank you very much

Rate This

5.0 / 5 (0 votes)

Etiquetas Relacionadas
Image ProcessingOpenCVPython TutorialDenoisingBlurringEdge DetectionMicroscope ImagesPre-processingMachine VisionData Segmentation
¿Necesitas un resumen en inglés?