Anyone can tell me why the imwrite make the image background become black, i inserted an image of something with background of white but after using code below i got perfect image but the background become black :
rgbImage = imread('wtmk.png'); redChannel = rgbImage(:, :, 1); greenChannel = rgbImage(:, :, 2); blueChannel = rgbImage(:, :, 3); reconImage=cat(3,redChannel,greenChannel,blueChannel); imwrite(reconImage,'watermark.png','png');
Anything wrong with my code ?
Please check whether size(rgbImage) is exactly the same as size(reconImage), and whether
all(rgbImage(:) == reconImage(:))
Your png file might be returning an alpha layer that you are not writing out to the new file.
What is the class of reconImage just before you call imwrite? You didn't somehow convert it (with code not shown) into double did you? Is it still uint8? Can you show the code where you "inserted an image of something with background of white" into your original rgbImage?
By the way, you don't need the third imwrite() argument of 'png' - it figures that out from the filename.