Not knowing your image it is hard to comment. May be it is dark because you are not looking at the full range? If you use regular Windows default viewer you may not see the full range, have you tried opening the image in imageJ or ZEN Lite and adjusting the brightness and contrast?
Thank you for explaining the part about the image being a float. I did not understand that, since I was using a float value for the Sigma parameter on an integer (0 - 255) image it wouldn't make much of a difference. Now I understand much better and the result is much more clearer.
Thank you so much for this incredible video! Apologies if this is somewhat of a naive question, but I was wondering if bm3d could also work on 1-dimensional data? For example, a typical image in the MNIST dataset has dimensions 28 x 28. So would this denoising technique still work if i were to flatten/reshape the image to 784 x 1 dimensions?
Not sure if bm3d is designed to work with RGB images. Go ahead and give it a try. If it doesn't work, I recommend splitting the color channels, performing the denoising on each channel and merging them back into a single RGB image.
Hello, I installed bm3d in my anaconda env, and i receive this error every time I try to run the program: AttributeError: module 'bm3d' has no attribute 'BM3DStages' My IDE does not show any errors when writing the code. Please let me know of a solution to this issue.
Your filename should not be the same as the bm3d library name. Save the file with another name and delete the previous file. The problem will be solved.
These videos have been a great help. Thank you for doing these! Do you have any recommendations for correcting non-uniform illumination in microscopy images? This is a regular issue I'm having and it's particularly problematic because a lot of the images I'm trying to analyze are mosaics (so the non-uniform illumination appears as a regular pattern).
I guess you mean shading correction? If so, try converting your image to LAB and then performing CLAHE on the L channel and then merging all channels together. I will probably create a video later but if you're in a hurry here is some code I just put together. import cv2 import numpy as np img = cv2.imread("images/Alloy_gradient.jpg", 1) #img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB) l, a, b = cv2.split(lab) clahe = cv2.createCLAHE(clipLimit=3, tileGridSize=(8,8)) clahe_img = clahe.apply(l) limg = cv2.merge((clahe_img,a,b)) image = cv2.cvtColor(limg, cv2.COLOR_LAB2BGR) cv2.imshow("Original image", img) cv2.imshow("Final image", image) cv2.waitKey(0) cv2.destroyAllWindows()
@@DigitalSreeni Thanks so much! Examining the problem more closely, my main issue appears to be photo-bleaching when I'm acquiring the mosaic. It's causing noticeable differences in image intensity from tile to tile. I tried performing rolling-ball background subtraction to even out the intensity, but some of the features in the samples I'm imaging (GFP-labeled tumors in cleared tissue) vary greatly in size, so it's difficult to choose a good size for the rolling-ball. However, applying clahe has improved segmentation greatly. Thanks again!
I am not sure what you mean by color reversed. RGB color images have 3 channels, R, G and B. If you read them with skimage then it reads them as RGB but if you use opencv then it reads them as BGR. If you followed my code as-is then you will be using skimage to read images. But I used cv2 to display them which is probably why you see colors reversed. Try converting your image from RGB to BGR before you display it: im_rgb = cv2.cvtColor(im_cv, cv2.COLOR_RGB2BGR) Or you can use opencv (cv2) to read images.
We don't change anything but yes the algorithm picks the reference block based on where the kernel location. Please read the original paper for better clarification.
I'll add it to my list. At work, we are considering adding cell tracking workflow to APEER. In case you aren't aware apeer.com is free image analysis platform in the cloud. Well, free for individuals, academia and non-profit. Check it out if you have time. Cell tracking is not there yet but hopefully we will have it soon.
Doing such an astounding job
sir i tried this method but have 2 problem.. why the processing is too long? and how to save it?
i mean i can save it but all is dark
Not knowing your image it is hard to comment. May be it is dark because you are not looking at the full range? If you use regular Windows default viewer you may not see the full range, have you tried opening the image in imageJ or ZEN Lite and adjusting the brightness and contrast?
@@DigitalSreeni not yet :)
Thank you for explaining the part about the image being a float.
I did not understand that, since I was using a float value for the Sigma parameter on an integer (0 - 255) image it wouldn't make much of a difference.
Now I understand much better and the result is much more clearer.
Does it have issues if the image is read from cv2 or isn't passed as float?
Thank you so much for this incredible video! Apologies if this is somewhat of a naive question, but I was wondering if bm3d could also work on 1-dimensional data? For example, a typical image in the MNIST dataset has dimensions 28 x 28. So would this denoising technique still work if i were to flatten/reshape the image to 784 x 1 dimensions?
@DigitalSreeni can you share it how to use for color images
Not sure if bm3d is designed to work with RGB images. Go ahead and give it a try. If it doesn't work, I recommend splitting the color channels, performing the denoising on each channel and merging them back into a single RGB image.
Hello, I installed bm3d in my anaconda env, and i receive this error every time I try to run the program: AttributeError: module 'bm3d' has no attribute 'BM3DStages'
My IDE does not show any errors when writing the code. Please let me know of a solution to this issue.
When I try to just check if the command bm3d.bm3d() compiles I receive the following error:
TypeError: 'module' object is not callable
Not sure how to help. If you've installed bm3d and properly using bm3d.bm3d then it shoudl work. Please look for any typos.
Your filename should not be the same as the bm3d library name. Save the file with another name and delete the previous file. The problem will be solved.
These videos have been a great help. Thank you for doing these! Do you have any recommendations for correcting non-uniform illumination in microscopy images? This is a regular issue I'm having and it's particularly problematic because a lot of the images I'm trying to analyze are mosaics (so the non-uniform illumination appears as a regular pattern).
I guess you mean shading correction? If so, try converting your image to LAB and then performing CLAHE on the L channel and then merging all channels together. I will probably create a video later but if you're in a hurry here is some code I just put together.
import cv2
import numpy as np
img = cv2.imread("images/Alloy_gradient.jpg", 1)
#img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
l, a, b = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=3, tileGridSize=(8,8))
clahe_img = clahe.apply(l)
limg = cv2.merge((clahe_img,a,b))
image = cv2.cvtColor(limg, cv2.COLOR_LAB2BGR)
cv2.imshow("Original image", img)
cv2.imshow("Final image", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Found even a better way...
# pip install opencv-rolling-ball
# Only works with 8 bit grey
import cv2
from cv2_rolling_ball import subtract_background_rolling_ball
img = cv2.imread("images/Alloy_gradient.jpg", 0)
final_img, background = subtract_background_rolling_ball(img, 30, light_background=True,
use_paraboloid=False, do_presmooth=True)
#optionally perform CLAHE to equalize histogram for better segmentation
clahe = cv2.createCLAHE(clipLimit=3, tileGridSize=(8,8))
clahe_img = clahe.apply(final_img)
cv2.imshow("Original image", img)
cv2.imshow("Background image", background)
cv2.imshow("AFter background subtraction", final_img)
cv2.imshow("After CLAHE", clahe_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
@@DigitalSreeni Thanks so much! Examining the problem more closely, my main issue appears to be photo-bleaching when I'm acquiring the mosaic. It's causing noticeable differences in image intensity from tile to tile. I tried performing rolling-ball background subtraction to even out the intensity, but some of the features in the samples I'm imaging (GFP-labeled tumors in cleared tissue) vary greatly in size, so it's difficult to choose a good size for the rolling-ball. However, applying clahe has improved segmentation greatly. Thanks again!
@@justinsmolen6285 Photo-bleaching can be a major pain. I'm glad CLAHE worked for you.
@@DigitalSreeni Thanks Sreeni for your videos! May you have any code for 3D images from CT for shading correction?
Hello sir I tried this method on my rgb image (by deleting as_gray=true) but the color reversed on my image how can I fix it?
I am not sure what you mean by color reversed. RGB color images have 3 channels, R, G and B. If you read them with skimage then it reads them as RGB but if you use opencv then it reads them as BGR. If you followed my code as-is then you will be using skimage to read images. But I used cv2 to display them which is probably why you see colors reversed. Try converting your image from RGB to BGR before you display it:
im_rgb = cv2.cvtColor(im_cv, cv2.COLOR_RGB2BGR)
Or you can use opencv (cv2) to read images.
Python for Microscopists by Sreeni Oh thank you I was using opencv now I see my mistake.
do we change the reference block each iteration
We don't change anything but yes the algorithm picks the reference block based on where the kernel location. Please read the original paper for better clarification.
Can you do a video on particle tracking/single cell tracking/edge tracking? Thank you so much for all your videos
I'll add it to my list. At work, we are considering adding cell tracking workflow to APEER. In case you aren't aware apeer.com is free image analysis platform in the cloud. Well, free for individuals, academia and non-profit. Check it out if you have time. Cell tracking is not there yet but hopefully we will have it soon.
can it even be used as an pop filter? jk, loved this explanation
Not sure what you mean by pop filter. This is just a denoising filter.