MATLAB: Free hand cropping an image

croppingfree handfreeformimage processingImage Processing Toolbox

Hello all,
I saw this post recently on this forum by Sean de Wolski on 19 Jun 2013. This is to free hand crop an image and blackout the rest. However, I'm using a jpg and it's causing the rest of my image to have a blueish tint. Do you know how to fix this? Thanks in advance!!
I = imread('cameraman.tif');
imshow(I);
h = imfreehand; %draw something
M = ~h.createMask();
I(M) = 0;
imshow(I);

Best Answer

Don't use jpg images. I never do. They are not suitable for doing image analysis. Use PNG format because it's lossless compression.
I used your code and did not get a bluish tint.