recover color on image
1 view (last 30 days)
Show older comments
i am converted rgb color image to im2bw format and gray scale image.
after i am extracted the boundary then i want to stored the the colored image.
please tell how to manage the color then recover or apply color for gray scale image and im2bw image
3 Comments
Image Analyst
on 10 Oct 2012
I'm not even sure what this means. Once you've thrown away the color info, it's gone, at least in those binary and gray images. Of course you still have the original rgb color image so you don't need to recover anything because you have the original.
Walter Roberson
on 10 Oct 2012
I think it means that they want to overlay the boundary lines on the color image.
Answers (1)
DGM
on 25 Sep 2024
I guess if I'm going to bump threads by fixing the formatting, I could at least try to answer them. This collection of threads is a handful of incomplete code and unclear objectives. I'm just going to assert objectives. We want to create a color composite image between a grayscale processed image and a set of perimeters from bwperim(). I assume that the collected blob properties, image contours, and boundary point lists that were the stars of prior posts were never actually relevant.
The only reason why I thought this was interesting was that this happened 12 years ago. In 2012, imoverlay(), labeloverlay(), and even the original FEX version of imoverlay() weren't options. MIMT was still an unrealized bad idea. Luckily, we can still use bsxfun() like it never went out of style.
% you have a grayscale image
inpict = imread('toyobjects.png');
% you binarize it somehow
mask = inpict~=127;
% you get the blob boundaries using bwperim()
maskp = bwperim(mask);
% do basic multiplicative composition
% since we're living in 2012, this uses bsxfun()
fgcolor = [0 1 0]; % pick a color
compmask = im2double(maskp);
fgc = bsxfun(@times,compmask,permute(fgcolor,[1 3 2]));
bgc = bsxfun(@times,(1-compmask),im2double(inpict));
outpict = im2uint8(bsxfun(@plus,fgc,bgc));
% show it or save it or whatever
imshow(outpict)
By chance, there is one anachonism in this example though. When I went to verify that everything would run in a period version, I found that the test image I had chosen didn't exist. The metadata suggests that toyobjects.png was last modified on October 5, 2012 -- only four days before this post was made. I figured I should leave it just to keep the time travelers on their toes.
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!