how can I change the color of portion of image where intensity is below threshold

2 views (last 30 days)
I have a grayscale image. I want to know the intensity of all pixels.
The pixel values in the color image will be replaced with a predefined color S (Purple) if the corresponding pixels in the grayscale image are less than the threshold value T as shown in the following equation,
๐‘‚(๐‘ฅ, ๐‘ฆ) = { ๐‘† ๐‘–๐‘“ ๐ผ๐‘ก (๐‘ฅ, ๐‘ฆ) > ๐‘‡
๐ผ๐‘ฃ (๐‘ฅ, ๐‘ฆ) ๐‘œ๐‘กโ„Ž๐‘’๐‘Ÿ๐‘ค๐‘–๐‘ ๐‘’
where ๐‘‚(๐‘ฅ, ๐‘ฆ) is the output intensity value at (๐‘ฅ, ๐‘ฆ),
๐ผ๐‘ก (๐‘ฅ, ๐‘ฆ) is the thermal intensity value at (๐‘ฅ, ๐‘ฆ),
๐ผ๐‘ฃ (๐‘ฅ, ๐‘ฆ) is the visible intensity value at (๐‘ฅ, ๐‘ฆ),
๐‘† is the predefined intensity value of color image, ๐‘‡ (80) is the threshold value of thermal image.
  1 Comment
DGM
DGM on 3 Feb 2023
Two things:
  • In order to provide an example, we need two images. We need a single-channel image representing temperature, and then we need a pseudocolor image which will be edited.
  • The equation you pasted states the opposite of your description. It states that the image regions which exceed the threshold are to be replaced.
So, do you have example images? What is the threshold and threshold behavior? What is the replacement color?
It may seem trivial that I would ask for the replacement color, but depending on the relationship between the replacement color and the colormap used by the pseudocolor image, the task may be simplified.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 3 Feb 2023
mask = grayImage < 80;
S = [68, 14, 98]; % Purple color.
outputImage = imoverlay(grayImage, mask, S);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!