Skip to main content
added an example of contrast measurement definition
Source Link
penelope
  • 3.7k
  • 1
  • 27
  • 67

Here's another example supporting the fact that the contrast is usually an attribute describing an object, either in relation to itself or to the surrounding. Another important fact to notice from this example is that contrast generally describes the difference between the intensity levels, but the precise definition depends on the application (purpose for the measurement). Let me paraphrase the contrast definition used in hierarchical image segmentation from P. Soille, L. Najman: On morphological hierarchical representations for image processing and spatial data clustering as an example:

The internal contrast of a connected component (object) corresponds to the largest intensity difference between two adjacent pixels belonging to this connected component. The external contrast is defined as the smallest intensity difference between a pixel of the considered connected component and an adjacent pixel not belonging to the considered component.

Of course, a different application could use a different measurement for contrast.

Here's another example supporting the fact that the contrast is usually an attribute describing an object, either in relation to itself or to the surrounding. Another important fact to notice from this example is that contrast generally describes the difference between the intensity levels, but the precise definition depends on the application (purpose for the measurement). Let me paraphrase the contrast definition used in hierarchical image segmentation from P. Soille, L. Najman: On morphological hierarchical representations for image processing and spatial data clustering as an example:

The internal contrast of a connected component (object) corresponds to the largest intensity difference between two adjacent pixels belonging to this connected component. The external contrast is defined as the smallest intensity difference between a pixel of the considered connected component and an adjacent pixel not belonging to the considered component.

Of course, a different application could use a different measurement for contrast.

Bounty Ended with 50 reputation awarded by Sufiyan Ghori
added a paragraph
Source Link
penelope
  • 3.7k
  • 1
  • 27
  • 67

So, it's actually just a simple scaling of image intensitiesscaling of image intensities (with cut-offs). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

On intensity adjustment

In term of greyscale image, the intensity of the pixel corresponds to it's brightness. The greater the intensity, the greater the brightness. This also means that increasing intensity can be viewed as brightening the image (while decreasing intensity can be viewed as darkening the image).

I would describe the process of uniformly brightening the image as increasing intensity while leaving the contrast unchanged in the whole image. This actually means adding a constant value to all the pixels.

Now, as the pixel intensity values have a predefined range, typically [0..255], this means that the maximum intensity exists. This inevitably means that some pixels (that were different from each other before) will become white (i.e. intensity 255).

This "naturally" happens when you take a photo aimed towards something very bright -- sun or other light. Away from the light, you might see some details, but at the position of the light/sun and around it, you will get only white pixels meaning that the intensity (amount of light when the image was taken) "hit" its maximum (displayable/storable) value.

The only way you wouldn't lose details by this operation would be if the original pixel intensities belong to only a part of possible intensity range, e.g. if original pixels are in the range [10, 150], the image could be brightened by up to 105 intensity levels before you start to loose details.

As imgadjust is meant to preform intensity scaling, it can do much more than just brighten/darken image. If you wanted to emulate brightening effect with imadjust, you could write something like:

imadjust(I, [0.0; x], [1.0-x; 1.0])

where x is any number between 0 and 1 (e.g. x=0.5 would brighten a [0..255] image by 127).

That said, this is an overkill for such a simple operation. I'm sure matlab has a elementary operation that adds a scalar to all elements of a matrix, so you could just use that :)

So, it's actually just a simple scaling of image intensities (with cut-offs). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

So, it's actually just a simple scaling of image intensities (with cut-offs). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

On intensity adjustment

In term of greyscale image, the intensity of the pixel corresponds to it's brightness. The greater the intensity, the greater the brightness. This also means that increasing intensity can be viewed as brightening the image (while decreasing intensity can be viewed as darkening the image).

I would describe the process of uniformly brightening the image as increasing intensity while leaving the contrast unchanged in the whole image. This actually means adding a constant value to all the pixels.

Now, as the pixel intensity values have a predefined range, typically [0..255], this means that the maximum intensity exists. This inevitably means that some pixels (that were different from each other before) will become white (i.e. intensity 255).

This "naturally" happens when you take a photo aimed towards something very bright -- sun or other light. Away from the light, you might see some details, but at the position of the light/sun and around it, you will get only white pixels meaning that the intensity (amount of light when the image was taken) "hit" its maximum (displayable/storable) value.

The only way you wouldn't lose details by this operation would be if the original pixel intensities belong to only a part of possible intensity range, e.g. if original pixels are in the range [10, 150], the image could be brightened by up to 105 intensity levels before you start to loose details.

As imgadjust is meant to preform intensity scaling, it can do much more than just brighten/darken image. If you wanted to emulate brightening effect with imadjust, you could write something like:

imadjust(I, [0.0; x], [1.0-x; 1.0])

where x is any number between 0 and 1 (e.g. x=0.5 would brighten a [0..255] image by 127).

That said, this is an overkill for such a simple operation. I'm sure matlab has a elementary operation that adds a scalar to all elements of a matrix, so you could just use that :)

corrected the examples
Source Link
penelope
  • 3.7k
  • 1
  • 27
  • 67

I don't usually work in MATLAB, but from the documentationdocumentation, it is used to map intensity range (intensity levels in given range) of an input image, to an intensity range specified for the output image. The default, no-parameter call, will increase contrast of the image. But, you can get a brighter/darker image with imadjust with either increasing or decreasing the object contrast. Let me demonstrate this on my 3rd example:

imadjust(I3, [200,[0.8; 255]1.0], [0,.0; 255]1.0])
imadjust(I3, [200,[0.8; 255]1.0], [0,.0; 55]0.2])

should output 0 0 0 0 5551 5551 0 0. Fairly dark object on a black background. The image is darker (lower intensity) and the contrast of the object did not change.

imadjust(I3, [200,[0.8; 255]1.0], [220,[0.85; 235]0.9])

should output 220216 220216 220216 235229 235229 220216 220216. Very bright object on bright background. The image is brighter (higher intensity), and the contrast of the object decreased (object intensity levels are more similar to the intensity levels of the background).

You get the actual ranges the function is working with by multiplying them with the maximum gray level (255). For example, a range [0.2; 0.8] is actually intensity range [51; 204].

One more thing to take care of is that the function clips the values outside the first intensity range, and maps them to the new low if they're smaller or new high if they're larger then the range. All of my examples actually include this: the first range starts from 0.8 which maps to intensity 204, but the intensity of 200 from the input image is mapped to the output low in all the images.

So, it's actually just a simple scaling of image intensities (with cut-offs, but I didn't demonstrate that in my examples). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

I don't usually work in MATLAB, but from the documentation, it is used to map intensity range (intensity levels in given range) of an input image, to an intensity range specified for the output image. The default, no-parameter call, will increase contrast of the image. But, you can get a brighter/darker image with imadjust with either increasing or decreasing the object contrast. Let me demonstrate this on my 3rd example:

imadjust(I3, [200, 255], [0, 255])
imadjust(I3, [200, 255], [0, 55])

should output 0 0 0 0 55 55 0 0. Fairly dark object on a black background. The image is darker (lower intensity) and the contrast of the object did not change.

imadjust(I3, [200, 255], [220, 235])

should output 220 220 220 235 235 220 220. Very bright object on bright background. The image is brighter (higher intensity), and the contrast of the object decreased (object intensity levels are more similar to the intensity levels of the background).

So, it's actually just a simple scaling of image intensities (with cut-offs, but I didn't demonstrate that in my examples). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

I don't usually work in MATLAB, but from the documentation, it is used to map intensity range (intensity levels in given range) of an input image, to an intensity range specified for the output image. The default, no-parameter call, will increase contrast of the image. But, you can get a brighter/darker image with imadjust with either increasing or decreasing the object contrast. Let me demonstrate this on my 3rd example:

imadjust(I3, [0.8; 1.0], [0.0; 1.0])
imadjust(I3, [0.8; 1.0], [0.0; 0.2])

should output 0 0 0 0 51 51 0 0. Fairly dark object on a black background. The image is darker (lower intensity) and the contrast of the object did not change.

imadjust(I3, [0.8; 1.0], [0.85; 0.9])

should output 216 216 216 229 229 216 216. Very bright object on bright background. The image is brighter (higher intensity), and the contrast of the object decreased (object intensity levels are more similar to the intensity levels of the background).

You get the actual ranges the function is working with by multiplying them with the maximum gray level (255). For example, a range [0.2; 0.8] is actually intensity range [51; 204].

One more thing to take care of is that the function clips the values outside the first intensity range, and maps them to the new low if they're smaller or new high if they're larger then the range. All of my examples actually include this: the first range starts from 0.8 which maps to intensity 204, but the intensity of 200 from the input image is mapped to the output low in all the images.

So, it's actually just a simple scaling of image intensities (with cut-offs). Also, the default call to imadjust with only an image as an input parameter should increase contrast. I'd say that imadjust(I2) wouldn't do anything (there's a maximum contrast in my second example).

Source Link
penelope
  • 3.7k
  • 1
  • 27
  • 67
Loading