From: Jack Branning on 22 Jul 2010 17:20 > You could also just use the 'BoundingBox' output of regionprops and segment everything inside that. Thanks again! I have been trying all your suggestions but have had no luck. To simplify things, I am now working off the following 10x10 matrix: A = 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 Where the zeros represent the regions of interest, where I need to extract the pixel data (here, the pixels are just 0). The centroid data I have is: c = 3 3 3 8 8 3 8 8 which represent the coordinates of the center pixels for each square. How can I obtain all the values for each 3x3 square for each of these coordinates?
From: Jeff on 23 Jul 2010 00:00 "Jack Branning" <jbr.nospam(a)nospam.com> wrote in message <i2acme$502$1(a)fred.mathworks.com>... > > > You could also just use the 'BoundingBox' output of regionprops and segment everything inside that. > > Thanks again! > > I have been trying all your suggestions but have had no luck. To simplify things, I am now working off the following 10x10 matrix: > > A = > > 1 1 1 1 1 1 1 1 1 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 1 1 1 1 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 1 1 1 1 1 1 1 1 1 > > Where the zeros represent the regions of interest, where I need to extract the pixel data (here, the pixels are just 0). > > The centroid data I have is: > > c = > 3 3 > 3 8 > 8 3 > 8 8 > > which represent the coordinates of the center pixels for each square. > > How can I obtain all the values for each 3x3 square for each of these coordinates? BoundingBox combined with imcrop won't work for this exact instance, as the handling of boundary pixels is...interesting. From the help section on imcrop: the output image includes all pixels in the input image that are completely or partially enclosed by the rectangle Here's what's working for me, which isn't using centroids: Ai = ~A; %turn 0's into 1's, and vice versa Ai_lab = bwlabel(Ai); % creates labeled image of all connected 1's for j = 1:max(max(Ai_lab)) %loop j through all connected components [ r c ] = find(Ai_lab == j); % return 1's row coordinates in r and columns in c Ai_struct.j = [r c]; % store each connected component's cooridnates end
From: Jeff on 23 Jul 2010 01:41 "Jeff " <jea(a)gene.dot.com> wrote in message <i2b449$130$1(a)fred.mathworks.com>... > "Jack Branning" <jbr.nospam(a)nospam.com> wrote in message <i2acme$502$1(a)fred.mathworks.com>... > > > > > You could also just use the 'BoundingBox' output of regionprops and segment everything inside that. > > > > Thanks again! > > > > I have been trying all your suggestions but have had no luck. To simplify things, I am now working off the following 10x10 matrix: > > > > A = > > > > 1 1 1 1 1 1 1 1 1 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 1 1 1 1 1 1 1 1 1 > > 1 1 1 1 1 1 1 1 1 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 0 0 0 1 1 0 0 0 1 > > 1 1 1 1 1 1 1 1 1 1 > > > > Where the zeros represent the regions of interest, where I need to extract the pixel data (here, the pixels are just 0). > > > > The centroid data I have is: > > > > c = > > 3 3 > > 3 8 > > 8 3 > > 8 8 > > > > which represent the coordinates of the center pixels for each square. > > > > How can I obtain all the values for each 3x3 square for each of these coordinates? > Sorry, I missed the part where you want to crop out a second image. Give this a try: Ai = ~A; %turn 0's into 1's, and vice versa Ai_lab = bwlabel(Ai); % creates labeled image of all connected 1's for j = 1:max(max(Ai_lab)) %loop j through all connected components Ai_temp = ismember(Ai_lab, j); %create matrix specific to one connected component at a time B_crop = B .* Ai_temp; %zero out any elements in original image B that aren't in Ai_temp B_crop = B_crop(any(B_crop), any(B_crop)); %remove any zero elements end
From: Sean on 23 Jul 2010 09:30 "Jack Branning" <jbr.nospam(a)nospam.com> wrote in message <i2acme$502$1(a)fred.mathworks.com>... > > > You could also just use the 'BoundingBox' output of regionprops and segment everything inside that. > > Thanks again! > > I have been trying all your suggestions but have had no luck. To simplify things, I am now working off the following 10x10 matrix: > > A = > > 1 1 1 1 1 1 1 1 1 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 1 1 1 1 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 0 0 0 1 1 0 0 0 1 > 1 1 1 1 1 1 1 1 1 1 > > Where the zeros represent the regions of interest, where I need to extract the pixel data (here, the pixels are just 0). > > The centroid data I have is: > > c = > 3 3 > 3 8 > 8 3 > 8 8 > > which represent the coordinates of the center pixels for each square. > > How can I obtain all the values for each 3x3 square for each of these coordinates? A =[... 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1]; c = [... 3 3 3 8 8 3 8 8]; %Ok you've successfully created an (inverse) mask; i.e. what you want right %now is 0 (false) and what you don't want is 1; true. %BWCONNCOMP with REGIONPROPS: CC = bwconncomp(~A); %(~A) means "NOT" A this is a logical condition to make your ROIs =1. RP = regionprops(CC,'PixelList','PixelIdxList'); %Note the two different properties I have: % -'PixelList' is a list of every [row col] coordinate of the points % -'PixelIdxList' is a list of direct indices to the points you want. % This is more useful but harder to visualize %Both of these are 4x1 struct arrays meaning that each component will have %the indices to each ROI. RP(1).PixelList %These are the direct coordinates to each of the nine members of ROI1 RP(1).PixelIdxList %These are the linear indexes in to A. For extracting values there are %easier and faster to use i.e. A(RP(1).PixelIdxList) %These are the values. %If A is the mask and B is the actual image then you would do: B(RP(1).PixelIdxList %for the image values %If you want to extract them with the PixelList you would need an additonal %call to sub2ind(). %Hope this helps
First
|
Prev
|
Pages: 1 2 Prev: Create a message 'Processing...' Next: How can i implement fourier transform in Simulink? |