Grayscale image segmentation using epanechnikov kernel - image

In the case of gray scale images, what to do if we get a decimal value like 65.5 as my convergence point in meanshift method?
How do we choose the window radius?

Related

Image intensity appears higher in MATLAB

I have a 2D DICOM images that appears (as it should do) to have a high intensity center, with the outside area having an intensity that approaches zero. When I load and view in MATLAB R2021b:
img=dicomread('image.dcm');
imshow(img);
The intensity appears much higher. I worry that this has affected the actual pixel intensity values and isn't just imshow trying to increase visibility. Has anyone any ideas how to get rid of this correction?
Regular image
,
Image in MATLAB

Digital Image Analysis Bilinear Interpolation

I am trying to understand the concept of bilinear interpolation. For example in the case where bilinear interpolation is used to rotate an image (let's say by 45 degrees), and then we rotate it back by the same amount. Is the resulting image the same as the original?
What about when an image is scaled up by a factor c, and then scaled down by the same factor c, is the resulting image the same as the original image?
In general, you will not get back the same values. I'll try and explain empirically...
Imagine a white rectangle on a black background, that will only have values of 255 (white) and 0 (black) in it. When you rotate it, the pixels on the edges of the rectangle will fall between pixels in the new image. At that point, you will end up interpolating between 0-255 and get some entirely new value, say 172. And now you immediately have a problem because bilinear interpolation has introduced a new value that wasn't in the original image and when you rotate back, you will end up interpolating between that new 172 and 255 or 0, which will give you yet another new value not present in the original image.
I hope that helps - it is the reason why you should use Nearest Neighbour interpolation when your pixels represent say classes in a Supervised Classification. You start off with water in class 0 and sand on the beach in class 17 beside it, and if you use Bilinear Interpolation to resize or geo-correct, you get a result of class 7 which might represent wheat - and you will rarely find wheat growing on a beach!

Image pixelation library, non-square "pixel" shape

I've seen a few libraries that pixelate images, some of them even feature non-square shapes such as The Pixelator's circle and diamond shapes.
I'm looking however to make a particular shape, I want a "pixel" that is 19x27 px. Essentially, the image would still look pixelated but it would use tallish rectangle shapes as the pixel base.
Are there any libraries out there that do this, if not, what alterations to existing algorithms/functions would I need to make to accomplish this?
Unless I am not understanding your question, the algorithm you need is quite simple!
Just break your image up into a grid of rectangles the size you want (in this case 19x27). Loop over each section of the grid and take the average color of the pixels inside (you can simply take the average of each channel in RGB independently). Then set all of the pixels contained inside to the average color.
This would give you an image that is the same size as your input. You could of course resize your image first to a more appropriate output size.
You might want to look up convolution matrices.
In a shader, you would use your current pixel location to grab a set of nearby pixels from the original image to render to a pixel in a new buffer image.
It is actually just a slight variation of the Box Blur image processing algorithm except that instead of grabbing from the nearby pixels you would grab by the divisions of the original image relative to the 19x27 divisions of the resulting image.

Why did I get very low negative SNR value of White Gaussian noise I added into a image

I'm using the following code to add white Gaussian noise to a 3D synthetic image I created. (100*100*100)
sigma = sqrt(10.0^(-snr/10.0));
r=x+sigma*randn(size(x));
I found that different ways of adding the noise need different range of SNR value.
eg. if I add noise stack by stack (x=image stack), the original image become invisible until SNR goes down to -50.
but when I try to add noise straight away in 3D, (x=3D image). the original image become invisible until SNR goes down to -5.
I've looked up everywhere but couldn't found solution of what causing this...could anyone please tell me if it's normal to have a 3D noisy image with SNR=-50dB or even -70dB? Or is there any way to know the true SNR of my noisy images?

CvBOX2D Processing

I've already got my ROI(CvBOX2D type) by series of contour processing, now I just want to focus on the image part within the ROI, e.g.: feed this part into another processing function, how can I do that? I know there is CvSetImageROI, but the type is CvRect, so I should convert CvBox2D to CvRect first? Or some way to apply a mask on it with the area outside the box set to 0?
Thanks in advance!
Only axis aligned ROIs are directly supported in OpenCV (CvRect or IplROI). This is because they allow direct access to the image memory buffer.
There are 2 ways to go about working on a non-axis aligned ROI in OpenCV. Neither of them is as efficient as using axis-aligned ROIs.
Rotate your image, or bounding box, so that your ROI is now axis aligned in the resulting rotated image.
Note: the rotation will slightly blur your image.
Use a mask: Draw your ROI as a white rectangle on a black BG the same size as the image, and give your processing functions this mask as the additional parameter.
Note: not all functions support masks.
I would recommend option 1 if you really must stay within the exact bounds of your ROI. Otherwise, just use the bounding rect.
Use c++ api of opencv. seriously. do it.
cv::Rect roi = cv::RotatedRect(box).boundingRect();
Mat_<type> working_area(original_mat, roi);
// now operate on working_area
Note: this will operate on the bounding rect. I didn't find information on how to create a mask out of rotatedrect. Probably you have to do it by hand in a scanline fashion.

Resources