MATLAB: How to encode and decode negative pixel to positive pixel in matlab

errorimage processingImage Processing Toolboxlossless image compressionnegative pixelpixel converterpositive pixel

hi, I want to ask. I have 512×512 image and I want to calculate the entropy. But, it has some error because the pixel contains negative value. Has anybody in here know how to do Matlab code to convert negative pixel to positive pixel and decode it back? please help me

Best Answer

Try this:
negPixels = grayImage < 0;
grayImage(negPixels) = 0; % or 1 or whatever you want.
Related Question