convert image in matlab

5 visualizzazioni (ultimi 30 giorni)
elham abk
elham abk il 3 Set 2013
Modificato: DGM il 22 Giu 2022
hello for all: am ask how to convert an image into hand-drawn image in matlab?

Risposte (2)

Image Analyst
Image Analyst il 3 Set 2013
There are various Photoshop tutorials to turn images into sketches or cartoons. You can do the same things in MATLAB if you can figure out what some of the filters do. For example: Photoshop sketch tutorials

DGM il 22 Giu 2022
Modificato: DGM il 22 Giu 2022
As IA notes, in order to find out how to do a Photoshop task in MATLAB, you figure out how to do it in Photoshop first. Translating the task to MATLAB is going to be difficult, since basic color adjustment, blending and compositing tools don't exist in base MATLAB or IPT. MIMT does have a lot of the basics covered, but it's still no Photoshop. Think of it as a half-baked GIMP-like in MATLAB.
Grabbing a couple textures and the first PS tutorial that showed up in a web search, I came up with this. It's not exactly a clone of the process, and I'm using blend modes that aren't available in PS, but the concept is similar.
% read base image
inpict = imread('peppers.png');
inpict = mono(inpict,'y'); % desaturate
sz = imsize(inpict,2);
% read sketch texture
sktexture = imread('sketchtexture1.jpg');
sktexture = imresize(sktexture,0.5); % scale
sktexture = imcrop(sktexture,[100 100 fliplr(sz)-1]); % crop out a region
sktexture = mono(sktexture,'y'); % desaturate
% read paper texture
ptexture = imread('papertexture1.jpg');
ptexture = imresize(ptexture,0.25); % scale
ptexture = imcrop(ptexture,[1 1 fliplr(sz)-1]); % crop out a region
% prepare edge layer
edges = imgaussfilt(inpict,3);
edges = imblend(iminv(edges),inpict,1,'colordodge');
edges = imlnc(edges,'independent','in',stretchlim(edges),'k',2,'g',2);
% prepare textured shading layer
shading = medfilt2(inpict,[17 17]); % reduce detail
shading = imflatfield(shading,50); % flatten
shading = imlnc(shading,'independent','k',2,'g',0.5);
shading = imblend(sktexture,shading,1,'contrast',1);
shading = imlnc(shading,'independent','k',2);
% blend layers
outpict = imblend(edges,shading,1,'multiply');
outpict = imblend(ptexture,outpict,1,'scaleadd',0.5);
It's not perfect. I probably could've used a better sketch texture, but it works well enough.
Then again, the question wasn't really ever clear about what "hand drawn" meant. There are other old techniques.
%% rotoscope/painting filter examples
inpict = imread('peppers.png');
% DGM's awful rotoscope filter
m = nhfilter(inpict,'median',10);
e2 = imadjust(255-edgemap(mono(m,'y')));
e2 = imadjust(e2,[0.5 0.9]);
B = imblend(e2,m,1,'multiply');
% Mark Lowry's "Landscape Painter" filter for GIMP's FXF circa 2006
darkenlayer = imgaussfilt(inpict,5);
C = imblend(darkenlayer,inpict,1,'darkenrgb');
outpict = [B; C];


Scopri di più su Convert Image Type in Help Center e File Exchange


Non è stata ancora inserito alcun tag.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by