# How to use LUT in image processing?

18 visualizaciones (últimos 30 días)
Maia2022 el 25 de Mayo de 2022
Comentada: Maia2022 el 26 de Mayo de 2022
Hi,
I have two images:
1. one binary image which can be used as a mask (BW) and
2. a grayscale image (Image).
I'd like to create an array (or a LUT) so that:
For each blob from the binary image, I can put all the corresponding values from the gray scale image.
How do I initialize the LUT? What would be the size of the LUT?
L = bwlabel(BW);
nbLabels = max(max(L));
for iBlob = 1:nbLabels
% find all coordinates of the current blob
[r, c] = find(L == iBlob);
rc = [r c];
values = Image(r,c); % rc may be Nx2
LUT(r, c) = values;
end
How to use this LUT later by indexing ?
Thank you very much.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Image Analyst el 25 de Mayo de 2022
Editada: Image Analyst el 25 de Mayo de 2022
I'm not sure what you want to do. It sounds like you're describing masking, where you have a binary image of blobs and black background, and you'd like the pixels inside the blob to have the original gray levels, and where the binary image is black you want the masked image to be black. To do that you'd do
maskedImage = grayImage; % Make copy of original image
maskedImage(~BW) = 0; % Erase image where it's black in the binary image.
Alternatively, you can also do it this way, which will work for both gray scale and RGB images:
maskedRgbImage = rgbImage .* cast(mask, 'like', rgbImage); % R2016b or later. Works for gray scale as well as RGB Color images.
% For R2016a or earlier, mask the image using bsxfun() function to multiply the mask by each channel individually. Works for gray scale as well as RGB Color images.
% maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage)); % R2016a or earlier.
I'm not sure how a lookup table would be involved here.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Maia2022 el 26 de Mayo de 2022
Thank you.

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Category Classification en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by