# AI News, Basic Image Data Analysis Using Python &#8211; Part 3

## Basic Image Data Analysis Using Python &#8211; Part 3

Previously we’ve seen some of the very basic image analysis operations in Python.

The intensity transformation function mathematically defined as: where r is the pixels of the input image and s is the pixels of the output image.

The log transformations can be defined by this formula: Where s and r are the pixel values of the output and the input image and c is a constant.

The value 1 is added to each of the pixel value of the input image because if there is a pixel intensity of 0 in the image, then log(0) is equal to infinity.

Gamma correction, or often simply gamma, is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems.

From there, we obtain our output gamma corrected image by applying the following equation: Where Vi is our input image and G is our gamma value.

1 is sometimes called an encoding gamma, and the process of encoding with this compressive power-law nonlinearity is called gamma compression;

The reason we apply gamma correction is that our eyes perceive color and luminance differently than the sensors in a digital camera.

Now, depending on the resolution and size of the image, it will see a 32 x 32 x 3 array of numbers where the 3 refers to RGB values or channels.

In machine learning terms, this flashlight is called a filter or kernel or sometimes referred to as weights or mask and the region that it is shining over is called the receptive field.

An image kernel or filter is a small matrix used to apply effects like the ones we might find in Photoshop or Gimp, such as blurring, sharpening, outlining or embossing.

As the filter is sliding, or convolving, around the input image, it is multiplying the values in the filter with the original pixel values of the image (aka computing element-wise multiplications).

After sliding the filter over all the locations, we will find out that, what we’re left with is a 30 x 30 x 1 array of numbers, which we call an activation map or feature map.

The reason we get a 30 x 30 array is that there are 900 different locations that a 3 x 3 filter can fit on a 32 x 32 input image.

So, in this case, the output would be Let’s say we’ve got a following 3x3 filter, convolving on a 5x5 matrix and according to the equation we should get a 3x3 matrix, technically called activation map or feature map.

However, For the pixels on the border of the image matrix, some elements of the kernel might stand out of the image matrix and therefore does not have any corresponding element from the image matrix.

In this case, we can eliminate the convolution operation for these positions which end up an output matrix smaller than the input or we can apply padding to the input matrix.

He is passionate about applying his knowledge of machine learning and data science to areas in healthcare and crime forecast where better solutions can be engineered in the medical sector and security department.

## Gamma correction

Gamma correction, or often simply gamma, is a nonlinear operation used to encode and decode luminance or tristimulus values in video or still image systems.&#91;1&#93;

Gamma encoding of images is used to optimize the usage of bits when encoding an image, or bandwidth used to transport an image, by taking advantage of the non-linear manner in which humans perceive light and color.&#91;1&#93;

The human perception of brightness, under common illumination conditions (not pitch black nor blindingly bright), follows an approximate power function (note: no relation to the gamma function), with greater sensitivity to relative differences between darker tones than between lighter ones, consistent with the Stevens' power law for brightness perception.

If images are not gamma-encoded, they allocate too many bits or too much bandwidth to highlights that humans cannot differentiate, and too few bits or too little bandwidth to shadow values that humans are sensitive to and would require more bits/bandwidth to maintain the same visual quality.&#91;1&#93;&#91;2&#93;

Although gamma encoding was developed originally to compensate for the input–output characteristic of cathode ray tube (CRT) displays, that is not its main purpose or advantage in modern systems.

However, the gamma characteristics of the display device do not play a factor in the gamma encoding of images and video—they need gamma encoding to maximize the visual quality of the signal, regardless of the gamma characteristics of the display device.&#91;1&#93;&#91;2&#93;

The similarity of CRT physics to the inverse of gamma encoding needed for video transmission was a combination of coincidence and engineering, which simplified the electronics in early television sets.&#91;4&#93;

For a power-law curve, this slope is constant, but the idea can be extended to any type of curve, in which case gamma (strictly speaking, 'point gamma'&#91;5&#93;) is defined as the slope of the curve in any particular region.

When a photographic film is exposed to light, the result of the exposure can be represented on a graph showing log of exposure on the horizontal axis, and density, or log of transmittance, on the vertical axis.

In particular, almost all standard RGB color spaces and file formats use a non-linear encoding (a gamma compression) of the intended intensities of the primary colors of the photographic reproduction;

In any case, binary data in still image files (such as JPEG) are explicitly encoded (that is, they carry gamma-encoded values, not linear intensities), as are motion picture files (such as MPEG).

The sRGB color space standard used with most cameras, PCs, and printers does not use a simple power-law nonlinearity as above, but has a decoding gamma value near 2.2 over much of its range, as shown in the plot to the right.

Output to CRT-based television receivers and monitors does not usually require further gamma correction, since the standard video signals that are transmitted or stored in image files incorporate gamma compression that provides a pleasant image after the gamma expansion of the CRT (it is not the exact inverse).

the reciprocal, approximately 2.33 (quite close to the 2.2 figure cited for a typical display subsystem), was found to provide approximately optimal perceptual encoding of grays.

The following illustration shows the difference between a scale with linearly-increasing encoded luminance signal (linear gamma-compressed luma input) and a scale with linearly-increasing intensity scale (linear luminance output).

On most displays (those with gamma of about 2.2), one can observe that the linear-intensity scale has a large jump in perceived brightness between the intensity values 0.0 and 0.1, while the steps at the higher end of the scale are hardly perceptible.

cathode ray tube (CRT), for example, converts a video signal to light in a nonlinear way, because the electron gun's intensity (brightness) as a function of applied video voltage is nonlinear.

In this case, when a video signal of 0.5 (representing a mid-gray) is fed to the display, the intensity or brightness is about 0.22 (resulting in a mid-gray, about 22% the intensity of white).

For this reason most formally defined colorspaces such as sRGB will define a straight-line segment near zero and add raising x + K (where K is a constant) to a power so the curve has continuous slope.

The display computer may use a color management engine to convert to a different color space (such as older Macintosh's γ = 1.8 color space) before putting pixel values into its video memory.

To see whether one's computer monitor is properly hardware adjusted and can display shadow detail in sRGB images properly, they should see the left half of the circle in the large black square very faintly but the right half should be clearly visible. If

It can be useful for making a monitor display sRGB images approximately correctly, on systems in which profiles are not used (for example, the Firefox browser prior to version 3.0 and many others) or in systems that assume untagged source images are in the sRGB colorspace.

On some operating systems running the X Window System, one can set the gamma correction factor (applied to the existing gamma value) by issuing the command xgamma -gamma 0.9 for setting gamma correction factor to 0.9, and xgamma for querying current value of that factor (the default is 1.0).

One contrasts relative luminance in the sense of color (no gamma compression) with luma in the sense of video (with gamma compression), and denote relative luminance by Y and luma by Y′, the prime symbol (′) denoting gamma compression.&#91;12&#93; Note

In common parlance, in many occasions the decoding value (as 2.2) is employed as if it were the encoding value, instead of its inverse (1/2.2 in this case), which is the real value that must be applied to encode gamma.

## Image Intensity Processing

The Reset button makes the 'maximum' 0 and the 'minimum' 255 in 8-bit images and the 'maximum' and 'minimum' equal to the smallest and largest pixel values in the image’s histogram for 16-bit images.

If the Auto button does not produce a desirable result, use the region-of-interest (ROI) tool to select part of the cell and some background, then hit the Auto button again.

If you prefer the image to be displayed as 'black on white' rather than 'white on black', then use the 'inverted' command: Image &#160;&#9654;

Recommended settings include: Do not save x-values (prevents slice number data being pasted into Excel) and Autoclose so that you don't have to close the analyzed plot each time.

The plugin Plot Z Axis Profile (this is the Z Profiler from Kevin (Gali) Baler (gliblr at yahoo.com) and Wayne Rasband simply renamed) will monitor the intensity of a moving ROI using a particle tracking tool.

If your two channels are opened as separate stacks, such as Zeiss, the two channels can be interleaved (mixed together by alternating between them) with the menu command Plugins &#160;&#9654;

From the second row downward, the first column is the time (slice number), the second column is the Ch1 mean intensity, and the third channel is the Ch2 mean intensity and the ratio value.

The LSM Toolbox is a project aiming at the integration of common useful functions around the Zeiss LSM file format, that should enhance usability of confocal LSM files kept in their native format, thus preserving all available metadata.

Select this time, copy it into Excel, and find the time number obtained by using the Excel menu command Edit &#160;&#9654;

Linescanning involves acquiring a single line, one pixel in width, from a common confocal microscope instead of a standard 2D image.

It will generate a pseudo-linescan 'stack' with each slice representing the pseudo-linescan of a single-pixel wide line along the line of interest.

The FRAP profiler plugin will analyze the intensity of a bleached ROI over time and normalize it against the intensity of the whole cell.

The intensity of each pixel is 'raised to the power' of the gamma value and then scaled to 8-bits or the min and max of 16-bit images.

Gaussian filter: This is similar to a smoothing filter but instead replaces the pixel value with a value proportional to a normal distribution of its neighbors.

In image analysis this process is generally used to produce an output image where the pixel values are linear combinations of certain input values.

'Minimum': This filter, also known as an erosion filter, is a morphological filter that considers the neighborhood around each pixel and, from this list of neighbors, determines the minimum value.

'Maximum': This filter, also known as a dilation filter, is a morphological filter that considers the neighborhood around each pixel and, from this list of neighbors, determines the maximum value.

Kalman filter: This filter, also known as the Linear Quadratic Estimation, recursively operates on noisy inputs to compute a statistically optimal estimate of the underlying system state.

HiLo LUT to display zero values as blue and white values (pixel value 255) as red.

With a background that is relatively even across the image, remove it with the Brightness/Contrast command by slowly raising the Minimum value until most of the background is displayed blue.

The user can choose whether or not to have a light background, create a background with no subtraction, have a sliding paraboloid, disable smoothing, or preview the results.

To speed up the process with an image that has a more even background, select a region of interest from the background and subtract the mean value of this area for each slice from each slice.

This macro will subtract the mean of the ROI from the image plus an additional value equal to the standard deviation of the ROI multiplied by the scaling factor you enter.

You can correct uneven illumination or dirt/dust on lenses by acquiring a 'flat-field' reference image with the same intensity illumination as the experiment.

This is often not possible with the experimental cover slip, so a fresh cover slip may be used with approximately the same amount of buffer as the experiment.

You can correct for uneven illumination and horizontal 'scan lines' in transmitted light images acquired using confocal microscopes by using the native FFT bandpass function ( Process &#160;&#9654;

Finally, the user can choose whether to allow autoscale after filtering, saturation of the image when autoscaling, whether or not to display the filter, and whether or not to process an entire stack.

In this tutorial you will learn how to: In this paragraph, we will put into practice what we have learned to correct an underexposed image by adjusting the brightness and the contrast of the image.

The brightness tool should be identical to the $$\beta$$ bias parameters but the contrast tool seems to differ to the $$\alpha$$ gain where the output range seems to be centered with Gimp (as you can notice in the previous histogram).

Gamma correction can be used to correct the brightness of an image by using a non linear transformation between the input values and the mapped output values: $O = \left( \frac{I}{255} \right)^{\gamma} \times 255$

1 \), the original dark regions will be brighter and the histogram will be shifted to the right whereas it will be the opposite with $$\gamma &gt; The overall brightness has been improved but you can notice that the clouds are now greatly saturated due to the numerical saturation of the implementation used (highlight clipping in photography). The gamma correction should tend to add less saturation effect as the mapping is non linear and there is no numerical saturation possible as in the previous method. After \( \alpha$$, $$\beta$$ correction, we can observe a big peak at 255 due to the saturation as well as a shift in the right.

Canon EOS C100 Tutorial Series - Waveform Monitor, Gammas, and Custom Pictures

Optimize EOS C100 exposure and image quality for your production needs with built-in tools like the waveform monitor, gamma settings, and Custom Picture ...

How to customize color settings in Photoshop CS6 | lynda.com

This Photoshop CS6 tutorial details how to change color settings and modify color profiles in Photoshop. Watch more at ...

How To Set up your TV for Games Correctly.

Use the Below image to check if your TV supports Full Range RGB or PC range. Simply download and stick on a USB and insert into your TV if it has a USB ...

In this session you will discover why your application doesn't look the same across multiple devices and why your designer's mock looks different on your ...

MATLAB tutorial: Image Processing Basic (6 functions in 4 mins)

This tutorial shows six fundamental MATLAB functions to use in image processing. The code can be found in the tutorial section in ...

Best Overwatch Settings! | Increase FPS and Reduce Input Lag Guide

RECOMMENDED SETTINGS BELOW! Timestamps: 0:30 - Graphical Settings 4:17 - Set up a bot game to test "True" FPS 5:30 - Check SIM value (Try to get it ...

My Monitor Settings for Competitive Gaming (Asus)

Hope this helped the people who requested it! MY MONITOR ...

Matlab Image Processing Tutorial includes histograms and imhist

Basic Image Processing in Matlab. This video introduces basic image processing commands. #Matlab #ImageProcessing #MatlabDublin.

Lecture - 21 Image Enhancement Frequency

Lecture Series on Digital Image Processing by Prof. P.K. Biswas , Department of Electronics & Electrical Communication Engineering, I.I.T, Kharagpur . For more ...

Dual Camera Smartphones: Explained!

Everything to know about dual cameras on smartphones. Video Gear I use: Intro Track: Ongoing Thing ..