How do I create vintage images in MATLAB? -
given colour image input, superimpose 3 images of same size following colors: green, black , blue.
for each of these images, change opacity:
- green = 40%
- black = 43%
- blue = 39%
once create these images, overlay input image image opacity of 38%. can help? take original image , apply vintage effect using matlab.
i've never created sepia / vintage effects on image using opacities speak of. create sepia / vintage images create output red, green , blue components using combination of input image's red, green , blue channels.
how create sepia / vintage images in way using following equations. supposing red, green , blue channels input image stored in inputred, inputgreen, , inputblue respectively. these equations recommended microsoft:
outputred = (inputred * .393) + (inputgreen *.769) + (inputblue * .189) outputgreen = (inputred * .349) + (inputgreen *.686) + (inputblue * .168) outputblue = (inputred * .272) + (inputgreen *.534) + (inputblue * .131) source: tech republic
outputred, outputgreen, outputblue output colour channels sepia / vintage image. such, read in image, extract each of colour planes, weighted combination each of output colour channels, combine channels together. should noted when read in image, of uint8 type. keep precision when multiplying decimal numbers, need cast image double before proceeding. once calculate sepia / vintage channels, you'll need cast result uint8 can display image save disk. such, here's code:
im = double(imread('...')); % // read in image here inputred = im(:,:,1); %// extract each colour plane inputgreen = im(:,:,2); inputblue = im(:,:,3); %// create sepia tones 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 putting of these 3d matrix %// , convert uint8 out = uint8(cat(3, outputred, outputgreen, outputblue)); figure; imshow(im,[]); %// show original image figure; imshow(out); %// show sepia image take note create 3d matrix again, use cat concatenates arrays / matrices in specified dimension. specified third dimension, want stack red, green , blue channels on top of each other form 3d matrix. cast result uint8.
here's example. decided take family portrait jon woodbury photography. appearing here don't know personally, letting me use picture nonetheless :)
when download image, run code image, output get:

sidenote - efficiency
the code above quite lot type out. can in 2 lines (three if consider reading in image step) if wish using combination of permute , reshape. need encapsulate sepia coefficients in 2d matrix, can calculate each output pixel matrix multiplication. such:
im = double(imread('...')); %// read in image %// define sepia matrix m = [0.393 0.769 0.189; 0.349 0.686 0.168; 0.272 0.534 0.131]; out = uint8(reshape((m*reshape(permute(im, [3 1 2]), 3, [])).', ... [size(im,1) size(im,2), 3])); you should same thing in output previous version of code! test, provided image in comments below:

this using modified code (really, you'll same results first version of code):

Comments
Post a Comment