From: Punkaj on 3 May 2010 16:15 Hi I want to do an analysis of an image using a planar 2-d interpolation. the image contains colored beads (data) and a white background (blank). I want to use the color information from the beads to interpolate the color throughout so that there is no white background. I am able to threshold out the white background with respect to the beads, so that my image only contains relevant data, but i am not sure how to use matlab to 'find' the closest beads to a white pixel (blank). I believe that if I can find the 3 closest beads (data) to a blank pixel, I could do a planar interpolation and obtain information for the blank pixel. any help in doing this would be greatly appreciated. currently I was analyzing the data using the following code, but this is no longer sufficient, but may help give an idea of what is trying to be done. function [output_image, display_image] = ColorIn8(input_image) %% Decompose colors of input_image into separate variables % this is done, though it is bulky, so that logical indexing can be used input_image1 = double(input_image(:,:,1)); input_image2 = double(input_image(:,:,2)); input_image3 = double(input_image(:,:,3)); % normalize normfactor = sqrt(double(input_image1.^2 + input_image2.^2 + input_image3.^2)); input_image1 = input_image1 ./ normfactor; input_image2 = input_image2 ./ normfactor; input_image3 = input_image3 ./ normfactor; % Scale to use entire range 0-1 input_image1 = (input_image1-(min(input_image1(:)))); input_image1 = input_image1 / max(input_image1(:)); input_image2 = (input_image2-(min(input_image2(:)))); input_image2 = input_image2 / max(input_image2(:)); input_image3 = (input_image3-(min(input_image3(:)))); input_image3 = input_image3 / max(input_image3(:)); %%thresholding content_mask = input_image3<.52 | input_image3>.69; disp('Please click on the center of the diffusion source, and press Enter'); figure; imagesc(input_image); [x,y] = ginput; %% Generate a mask, with a small disk over the diffusion source mask = false(size(input_image, 1), size(input_image, 2)); mask(round(y-2:y+2), round(x-2:x+2)) = true; %% Initialize variables for each color of the output image: output_image1 = zeros(size(input_image, 1), size(input_image, 2)); output_image2 = zeros(size(input_image, 1), size(input_image, 2)); output_image3 = zeros(size(input_image, 1), size(input_image, 2)); %% Set region corresponding to the diffusion source in output image to be % the mean of that area in input image output_image1(mask) = mean(input_image1(mask & content_mask)); output_image2(mask) = mean(input_image2(mask & content_mask)); output_image3(mask) = mean(input_image3(mask & content_mask)); %% Grow mask symmetrically and radially, filling in the mean values of each % "doughnut" in the output image % define structuring element for dilation: SE = strel('disk', 30, 0); while ~all(mask(:)) % while there are still values to be filled in % make the mask a little bigger new_mask = imdilate(mask, SE); % work only in the area where we have not worked before: doughnut = xor(new_mask, mask); % set mean of each color in the ring to the color specified by the mean output_image1(doughnut) = mean(input_image1(doughnut & content_mask)); output_image2(doughnut) = mean(input_image2(doughnut & content_mask)); output_image3(doughnut) = mean(input_image3(doughnut & content_mask)); % prepare mask for next iteration mask = new_mask; end %% Reform color image for output output_image = [output_image1, output_image2, output_image3]; output_image = reshape(output_image, size(input_image)); %% Generate display_image, and overlay of input and output images display_image = .7*output_image + .3*(double(input_image)./repmat(normfactor, [1,1,3])); end
From: ImageAnalyst on 3 May 2010 17:09 On May 3, 4:15 pm, "Punkaj " <p...(a)case.edu> wrote: > Hi I want to do an analysis of an image using a planar 2-d interpolation. the image contains colored beads (data) and a white background (blank). I want to use the color information from the beads to interpolate the color throughout so that there is no white background. [code snipped] ---------------------------------------------------------------------------------------------------------------------- Well we can't do much with that code because you forgot to post your image. Go to http://drop.io and post your image. Otherwise I can't really help much... I didn't really understand your explanation so a picture would help. You said you could threshold into background and beads, and that you want to "interpolate" the bead color into the background pixels. It sounds like you're wanting the function roifill(), but I'm not sure, since this "I want to use the color information from the beads to interpolate the color throughout so that there is no white background. " doesn't exactly descirbe what roifill does.
From: Punkaj on 3 May 2010 17:25 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4fae789a-6511-4f6d-856f-d861b28e3438(a)r9g2000vbk.googlegroups.com>... > On May 3, 4:15 pm, "Punkaj " <p...(a)case.edu> wrote: > > Hi I want to do an analysis of an image using a planar 2-d interpolation. the image contains colored beads (data) and a white background (blank). I want to use the color information from the beads to interpolate the color throughout so that there is no white background. > [code snipped] > ---------------------------------------------------------------------------------------------------------------------- > Well we can't do much with that code because you forgot to post your > image. > Go to http://drop.io and post your image. Otherwise I can't really > help much... > > I didn't really understand your explanation so a picture would help. > You said you could threshold into background and beads, and that you > want to "interpolate" the bead color into the background pixels. It > sounds like you're wanting the function roifill(), but I'm not sure, > since this "I want to use the color information from the beads to > interpolate the color throughout so that there is no white background. > " doesn't exactly descirbe what roifill does. http://drop.io/ihayytg i have posted an image here. thanks for your help.
From: ImageAnalyst on 3 May 2010 19:08 I still don't know what you want to do. Your threshold gives a decent looking result, but then what you're doing after that is confusing. What are you really after? Are you after the background as if there weren't any particles in there? If so, why? Is the background your actual object you're interested in and the particles are just garbage to be eliminated? Or is it the particles that you are really interested in? Either way it looks like you have both so I'm not sure what the growing annular mask thing is about (where you're setting the color of all the annular regions around all the irregularly shaped particles equal to the average color of all those annular regions.)
From: Punkaj on 3 May 2010 20:19
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4bec2d38-ac7f-4a5d-8396-60bfc4a62f2f(a)i9g2000vbh.googlegroups.com>... > I still don't know what you want to do. Your threshold gives a decent > looking result, but then what you're doing after that is confusing. > What are you really after? Are you after the background as if there > weren't any particles in there? If so, why? Is the background your > actual object you're interested in and the particles are just garbage > to be eliminated? Or is it the particles that you are really > interested in? Either way it looks like you have both so I'm not sure > what the growing annular mask thing is about (where you're setting the > color of all the annular regions around all the irregularly shaped > particles equal to the average color of all those annular regions.) I want the white areas to represent colors of beads in nearby regions. the color of the beads represents a pH concentration of surrounding area. the file i have posted, as you said, uses mean, which is not accurate enough. This is why i want to use interpolation. Another reason is I also do not want it to be simply spherical. I would like it to go pixel by pixel and define the white pixels by interpolation using color information from three closest beads. To try to reiterate, I would like to use the beads color information, to planar interpolate colors into the white areas so that it provides a color map across the entire image. Again thanks for your time and help. |