How to import pictures and manipulate them for further modeling purposes

3 views (last 30 days)
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
kenneth86
kenneth86 on 9 Nov 2012
Sorry, wrong links. I have updated them now.
Now, I'm not really sure on what you mean by doing it in Illustrator. I make the plots in Illustrator to make a reliable model (something which I can not directly do in matlab) and then import it into matlab where I am going to further do some calculations on my model. The pictures that I have exportet from Illustrator is in png format, but I have no idea or experience on what format or properties that I should export my image in. All tips are welcomed with gratitude :-)
Image Analyst
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?

Sign in to comment.

Accepted Answer

Image Analyst
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);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!