How to logical AND gray scale image with a constant?

1 visualización (últimos 30 días)
Jes
Jes el 4 de Ag. de 2015
Comentada: Jes el 4 de Ag. de 2015
ANDing an 8-bit gray level image with a constant value of 240 (11110000 in binary)?

Respuesta aceptada

Image Analyst
Image Analyst el 4 de Ag. de 2015
Use bitand():
n1 = uint8(170); % Some number
n2 = uint8(240);
% Show what they are
dec2bin(n1)
dec2bin(n2)
% And them
out = bitand(n1, n2)
% Show result
dec2bin(out)
ans =
10101010
ans =
11110000
out =
160
ans =
10100000
It works for images as well as individual numbers.
  1 comentario
Jes
Jes el 4 de Ag. de 2015
Thank you very much. Could you please tell me What could be the effect of anding 240 with grayscale image? clc; clear all; close all; I=imread('cameraman.tif'); n1 = uint8(I); % Some number n2 = uint8(240); figure;imshow(I); out = bitand(n1, n2); figure; imshow(out);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox 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