How to import pictures and manipulate them for further modeling purposes
3 views (last 30 days)
Show older comments
Hello everyone,
I have a geological model that I have drawn in Adobe Illustrator (see https://picasaweb.google.com/118274213935472393003/MatlabIssue?authuser=0&feat=directlink#5808738904821184514 ) and subsequently imported it into matlab by using the imread function. Now, my objective is to assign each of the various layers with its unique color a distinct value, e.g. the green layers should have a value of 0.5. The result would be a matrix with elements corresponding to the assigned value for a given pixel of the picture. So, since I know the color value of each pixel that the imread function have assigned, I have simply given the pixels for a given color a corresponding value. However, at the layer interfaces there are no sharp edges (see https://picasaweb.google.com/118274213935472393003/MatlabIssue?authuser=0&feat=directlink#5808738968570071538 ), so the transition of pixels between interfaces are faded. Hence, the pixels located around the interfaces have different values to the layers I am intrested in. Question: Are there any other clever ways of importing pictures with limited resolution and import it into matlab for further modeling? (Here is a plot of how I basically want it to look like: https://picasaweb.google.com/118274213935472393003/MatlabIssue?authuser=0&feat=directlink#5808743973055340626
Best regards, Kenneth
3 Comments
Image Analyst
on 9 Nov 2012
Why can't you simply draw in the desired color instead of trying to draw in some color you don't want and then change it in MATLAB. Did you ever seem my answer below?
Accepted Answer
Image Analyst
on 9 Nov 2012
Just extract each color channel:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Then replace each pixel you need to
redChannel(redChannel == oldRedValue) = newRedValue;
etc.
Then blur to anti-alias (smooth the edges):
redChannel = conv2(redChannel, ones(3));
Then recombine to form the new RGB output image:
newRGBImage = cat(3, redChannel, greenChannel, blueChannel);
0 Comments
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading 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!