From: eli goodwin on 6 Jul 2010 20:05 I am trying to measure the change in area of an object for a neurophysiology assay. Currently, I load a video, crop it, apply a rgb filter to the frames of interest and pass that information onto bwlabel. I use bwlabel and regionprops to calculate the change in area for each frame, saving the data as a vector providing me with a nice curve. My problem is this: i want to calculate the area of an individual object, while excluding other objects in frame within the parameters of rgb filter . The rgb filter works okay but it can be too lax or stringent depending on the circumstances. I want to use roipoly on the first frame of the avi to create a roi reference as my first filter. I am lost on how to tell matlab to ignore the pixels outside of the mask and to apply the rgb filter on the pixels that are relevant for each frame. Most of the following script was written by someone else and I do not know how to implement roipoly filter into here. [frame, Map] = frame2im(immov(1)); image(frame); imwrite(frame, 'frame.jpg', 'jpg'); i=imread('frame.jpg'); mask=roipoly(i); %pix = [140 119 68];%pix = minimum values, pix2 = maximum values for each type % %pix2 = [162 137 76]; pix = [30 119 68]; pix2 = [30 135 68]; for k=1:size(immov,2) im{k}=immov(k).cdata; end H.mov=figure; resx=size(immov(1).cdata,2); resy=size(immov(1).cdata,1); set(H.mov,'position',[10 10 resx resy]) set(gca,'position',[0.001 0.001 0.999 0.999]) colormap gray axis off for j=1:length(im) m = (im{j}(:,:,1)>pix(1)&im{j}(:,:,1)<pix2(1) & im{j}(:,:,2)>pix(2)&im{j}(:,:,2)<pix2(2)); lbl = bwlabel(m); s = regionprops(lbl,'area'); areas = cat(1,s.Area); if isempty(areas) trackarea(j)=0; else trackarea(j)=areas(1); end if ~isempty(areas) [Y,I] = sort(areas); %disp(j); biggest = (lbl == I(end)); imagesc(biggest);drawnow; bkmov(j).cdata = double(biggest)*256; bkmov(j).colormap = immov(j).colormap; as(j)=Y(end); else bkmov(j).cdata = bkmov(1).cdata; bkmov(j).colormap = bkmov(1).colormap; as(j)=0; end end trackarea=trackarea(1:end);
From: ImageAnalyst on 6 Jul 2010 21:27 If you have the mask, simply pass it into bwlabel() to get a labeled image. labeledImage = bwlabel(maskImage, 8); % Label each blob so we can make measurements of it Then pass the labeled image into regionprops() along with your original image to get the measurements. You might have to pass in each color band one at a time to get all of them (but maybe not - I usually deal with monochrome images or do the color images one band at a time.) % Extract the individual red, green, and blue color planes. redChannel= rgbImage(:, :, 1); greenChannel= rgbImage(:, :, 2); blueChannel= rgbImage(:, :, 3); % Get all the blob properties. Can only pass in originalImage in version R2008a and later. blobMeasurementsR = regionprops(labeledImage, redChannel, 'all'); blobMeasurementsG = regionprops(labeledImage, greenChannel, 'all'); blobMeasurementsB = regionprops(labeledImage, blueChannel, 'all');
From: eli goodwin on 7 Jul 2010 14:45 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <676a591c-bbba-465d-b3ee-1a70eee9d5a2(a)i31g2000yqm.googlegroups.com>... > If you have the mask, simply pass it into bwlabel() to get a labeled > image. > > labeledImage = bwlabel(maskImage, 8); % Label each blob so we can > make measurements of it > > Then pass the labeled image into regionprops() along with your > original image to get the measurements. You might have to pass in > each color band one at a time to get all of them (but maybe not - I > usually deal with monochrome images or do the color images one band at > a time.) I tried this lblmask = bwlabel(mask) then further along... s = regionprops(lbl, lblmask, 'area'); and it didn't work. no areas were calculated and the resulting binary video was empty (all black).
From: eli goodwin on 7 Jul 2010 16:31 Does anyone have any ideas how to do this? Passing the mask onto regionprops does not work for some reason.
From: eli goodwin on 12 Jul 2010 19:25 "eli goodwin" <egoodwin(a)uoregon.edu> wrote in message <i12o6o$lga$1(a)fred.mathworks.com>... > Does anyone have any ideas how to do this? Passing the mask onto regionprops does not work for some reason. I found a simple solution; take the mask and perform an array operation (mask.*) against the RGB threshold values 'm.' Both are logical arrays and the only values left are those within the mask meeting the RGB threshold values.
|
Next
|
Last
Pages: 1 2 Prev: Diagonal matrix recognition Next: what does mean " Multichannel Image " |