how can change the value of one bit in a pixcel
Show older comments
imatlab every pixcel save as decimal i want to cchange the value of 1 bit for example if the value of pixcel is 2 i chnged it to binary it is 00000010 i want if its 7 bit is 0 it change to 1 and its 7 bit is 1 it change to 0
Answers (2)
Azzi Abdelmalek
on 10 Jan 2014
a='00000010',
a(7)=num2str(not(str2num(a(7))))
Image Analyst
on 10 Jan 2014
Look at this snippet from my attached watermarking demo:
% Set the bit of originalImage(a copy, actually) to the value of the watermark.
watermarkedImage = originalImage; % Initialize
for column = 1 : visibleColumns
for row = 1 : visibleRows
watermarkedImage(row, column) = bitset(originalImage(row, column), bitToSet, watermark(row, column));
end
end
See how it takes the original pixel, originalImage(row, column), and sets bit number "bitToSet" to a 0 or 1 value, watermark(row, column)
In its simplest form
outputPixelValue = bitset(originalPixelValue, bitToSet, desiredBitSetting);
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!