Normalize an image using the mean pixel value in a ROI - imagej

I want to normalize several images in imageJ using the mean pixel value in a ROI, so that after normalization the mean in this ROI has the same value in all the images. How can I do it? Thanks

It is hard to say with out a particular example but a priory I would select the ROI and press control + Mto measure the region. If it is grey scale image you should obtain the gray mean of the grey pixels. You can use then this value to divide all the pixels in you image using Divide function under the Process > Math menu. If you calculate the mean for each image and use that value to divide each corresponding image, your ROI should have the same mean value for all ROI in your pictures.
I hope it helps!

Related

Blurring image with RGB values without convolving it with a kernel

I'm using an app for face redaction that doesn't allow access to the source code but only allows me to pass pixel values for red, green and blue channel upon which it creates a matrix with the same average RGB values for every ROI pixel value. For eg. if I give Red=32,Blue=123 and Green=233 it will assign these RGB values for every pixel of the ROI and then draws a colored patch on the face.
So I was wondering is there a general combination of RGB values of a pixel to distort it and make it look like it's blurred. I can also set the opacity value in the app.
Thanks.

Calculate the perceived brightness of an image

I wanna calculate the perceived brightness of an image and classify the image into dark, neutral and bright. And I find one problem here!
And I quote Lakshmi Narayanan's comment below. I'm confused with this method. What does "the average of the hist values from 0th channel" mean here? the 0th channel refer to gray image or value channel in hsv image? Moreover, what's the theory of that method?
Well, for such a case, I think the hsv would be better. Or try this method #2vision2. Compute the laplacian of the gray scale of the image. obtain the max value using minMacLoc. call it maxval. Estimate your sharpness/brightness index as - (maxval * average V channel values) / (average of the hist values from 0th channel), as said above. This would give you certain values. low bright images are usually below 30. 30 - 50 can b taken as ok images. and above 50 as bright images.
If you have an RGB color image you can get the brightness by converting it to another color space that separates color from intensity information like HSV or LAB.
Gray images already show local "brightness" so no conversion is necessary.
If an image is perceived as bright depends on many things. Mainly your display device, reference images, contrast, human...
Using a few intensity statistics values should give you an ok classification for one particular display device.

Determining pixel coordinates across display resolutions

If a program displays a pixel at X,Y on a display with resolution A, can I precisely predict at what coordinates the same pixel will display at resolution B?
MORE INFORMATION
The 2 display resolutions are:
A-->1366 x 768
B-->1600 x 900
Dividing the max resolutions in each direction yields:
X-direction scaling factor = 1600/1366 = 1.171303075
Y-direction scaling factor = 900/768 = 1.171875
Say for example that the only red pixel on display A occurs at pixel (1,1). If I merely scale up using these factors, then on display B, that red pixel will be displayed at pixel (1.171303075, 1.171875). I'm not sure how to interpret that, as I'm used to thinking of pixels as integer values. It might help if I knew the exact geometry of pixel coordinates/placement on a screen. e.g., do pixel coordinates (1,1) mean that the center of the pixel is at (1,1)? Or a particular corner of the pixel is at (1,1)? I'm sure diagrams would assist in visualizing this--if anyone can post a link to helpful resources, I'd appreciate it. And finally, I may be approaching this all wrong.
Thanks in advance.
I think, your problem is related to the field of scaling/resampling images. Bitmap-, or raster images are digital photographs, so they are the most common form to represent natural images that are rich in detail. The term bitmap refers to how a given pattern (bits in a pixel) maps to a specific color. A bitmap images take the form of an array, where the value of each element, called a pixel picture element, correspond to the color of that region of the image.
Sampling
When measuring the value for a pixel, one takes the average color of an area around the location of the pixel. A simplistic model is sampling a square, and a more accurate measurement is to calculate a weighted Gaussian average. When perceiving a bitmap image the human eye should blend the pixel values together, recreating an illusion of the continuous image it represents.
Raster dimensions
The number of horizontal and vertical samples in the pixel grid is called raster dimensions, it is specified as width x height.
Resolution
Resolution is a measurement of sampling density, resolution of bitmap images give a relationship between pixel dimensions and physical dimensions. The most often used measurement is ppi, pixels per inch.
Scaling / Resampling
Image scaling is the name of the process when we need to create an image with different dimensions from what we have. A different name for scaling is resampling. When resampling algorithms try to reconstruct the original continuous image and create a new sample grid. There are two kind of scaling: up and down.
Scaling image down
The process of reducing the raster dimensions is called decimation, this can be done by averaging the values of source pixels contributing to each output pixel.
Scaling image up
When we increase the image size we actually want to create sample points between the original sample points in the original raster, this is done by interpolation the values in the sample grid, effectively guessing the values of the unknown pixels. This interpolation can be done by nearest-neighbor interpolation, bilinear interpolation, bicubic interpolation, etc. But the scaled up/down image must be also represented over discrete grid.

Estimate average brightness of a grayscale picture with opencv

I have a grayscale picture, and I would to transform it to black and white only. But for that, I need to calculate the right threshold, and I would like that threshold to be equal to the average brightness of the picture.
So, I was wondering how I could calculate that threshold with OpenCV. Is there a method existing in the framework to do that easily ?
I wanted to add every value of brightness (between 0 and 255) for every pixel, then divide the sum by the number of pixel itself, but the method I found to access those datas is really slow (.at(i,j)[k] for a rgb picture). But my picture is in grayscale, and I would like it to be quite fast, so it can be run on an iPhone.
To calculate these statistics, use cv::sum(), or even better, cv::mean().
However, OpenCV already has a thresholding function that does everything you want to do for you:
cv::adaptiveThreshold()
Also you should check out Otsu's method, see cv::threshold() with THRESH_OTSU option.
You can use a Monte Carlo algorithm, sampling random points instead of all image points until you have covered 1% of the image. The result should be very similar to the actual value.

wind filter in opencv

Could someone suggest me how to go about getting the wind filter effect in opencv similar to the one available in photoshop and gimp?
Here is an image of text with wind styled filter applied on it.
Thanks
I suggest the following steps:
Use the original text image as a mask. White pixels are '1', blacks are '0'.
Smooth the image in X direction (like in the example image you added)
You can do the smoothing by
horizontal vector filter
or use distance transform where
distance is calculated only along x
axis.
I think that distance transform will
run faster
Multiply the result by (1-mask) so smoothing will occur only outside the text.
Multiply each row of the result by random number in range [0.1 ..1]. This will make smoothing uneven.
Add to the result the original image of the text to get the final image

Resources