필터 지우기
필터 지우기

how to make 3 lsbs set to zero

조회 수: 2 (최근 30일)
niranjan v
niranjan v 2019년 3월 14일
답변: Raghunandan V 2019년 3월 14일
an rgb image have 8 bit image and how to make last 3 least significant bits to zero of each and every pixel in the image

답변 (2개)

Raghunandan V
Raghunandan V 2019년 3월 14일
Step1: load the rgb image
step2: create a matrix image(x,y,:)
Step3: convert values to binary>> de2bi
Step4: replace the 3 lbs to zero
Step5: convert them back to decimal>> d =bi2de(b)
  댓글 수: 1
niranjan v
niranjan v 2019년 3월 14일
thanku so much sir please can you provide any sample code to replace the 3 lsbs to zero

댓글을 달려면 로그인하십시오.


Raghunandan V
Raghunandan V 2019년 3월 14일
I have written a sample code. Please take a look at it.
one point to be noted would be when you convert a decimal to binary in matlab. The value gets converted to a set of chars data units. This is because for a matrix to have zero as decimal means to have nothing but its not the same case with binary as binary is a set of charatcers.
%load the image into the matlab
Test = imread('Sample.jpg');
%convert the complete image into binary
TestBin = dec2bin(Test);
% replace the 3lsb's by 0
TestBin(:, 6:8) = '0';
% convert back to decimal
TestNew = bin2dec(TestBin);
%reshape to the input image size
TestNew = reshape(TestNew, size(Test));
%display the image
imshow(TestNew);

Community Treasure Hunt

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

Start Hunting!

Translated by