How to create sepia image in gui?
Show older comments
global im
is=im;
inputRed = im(:,:,1); %// Extract each colour plane
inputGreen = im(:,:,2);
inputBlue = im(:,:,3);
%// Create sepia tones for each channel
outputRed = (inputRed * .393) + (inputGreen *.769) + (inputBlue * .189);
outputGreen = (inputRed * .349) + (inputGreen *.686) + (inputBlue * .168);
outputBlue = (inputRed * .272) + (inputGreen *.534) + (inputBlue * .131);
%// Create output image by putting all of these back into a 3D matrix
%// and convert back to uint8
out = uint8(cat(3, outputRed, outputGreen, outputBlue));
axes(handles.axes2);
imshow(is);
That's my code, but Sepia is suposed to be more.. yellow
Answers (1)
Geoff Hayes
on 20 Nov 2015
Rossana - look at your last line of code
imshow(is);
You are displaying the original image is when you want to display the modified one out as
imshow(out);
As an aside you may want to rename your sepia image variable to something more meaningful like sepiaImg.
3 Comments
Rossana Parada
on 23 Nov 2015
Geoff Hayes
on 24 Nov 2015
I was able to use your above code to generate a sepia image from my original, so perhaps there was something incorrect about your image (?).
Image Analyst
on 24 Nov 2015
The copper look up table (colormap) only applies to a monochrome (grayscale) image. Not sure which monochrome image you applied
colormap(copper(256));
to. Like maybe one of the color channels??? But you can't apply it to a floating point, or uint8, RGB color image - it will be ignored since a colormap only applies to, and makes sense for, grayscale or indexed images.
Regarding the black image, in your unshown code where you call imwrite() to write "out" out (to disk), you need to convert to uint8, otherwise you might get all black (like you did) or possibly all white or gibberish (not sure since that's not the right thing to do, so I never do it to check on it).
Categories
Find more on Convert Image Type 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!