Hi Bindhu,
To apply histogram equalization to an image and ensure that the resulting pixel values are constrained within a specific range “[13, 242]” instead of the default “[0, 255]”, I would suggest a few modifications to the code mentioned above:
- “histeq” function works only on grayscale image. If the image is RGB (colored), it needs to be converted to grayscale.
- Use “imadjust” function is used to map the intensity values of the image from the range [13, 242] to the full range [0, 255].
adjusted_img = imadjust(img, [13/255, 242/255], []);
- “[13/255, 242/255]” specifies the input range in normalized form (since image intensity values are typically in the range 0 to 1 for processing).
- “[]” specifies that the full output range [0, 1] should be used.
- “histeq” function is used to perform histogram equalization on the intensity-adjusted image.
- This enhances the contrast of the image by spreading out the most frequent intensity values.
rr = histeq(adjusted_img);
title('Histogram-Equalized Image with Adjusted Range');
For more information on “histeq”, “imadjust”, “rgb2gray” functions please refer to the following documentation links:
Hope this helps.