Prev: chebychev polynomials 2d,3d
Next: Source code for a Shape Classification Using Fourier Descriptors with shape signature
From: smith Og on 28 Jul 2010 11:01 Hi Guys, I have two gray scale or binary images, A and B A is 4096 by 4096 B is 248 by 248 both images contains the same shape: 4 white recatangles on each side not touching each other. The rectangles in image B is much bigger than in A, but similar symmetry. My problem is how do I make the rectangles in image B about the same size as in A. Note - 1. Both images contains 4 white rectangles, and the remaining is just a black backgorund. 2. Both were produced by cameras, and I know the pixel lenght if that would be of any help. In a nutshell, I want the image in B, to have about the same size of white rectangles in A, and the remaining part of the image will be the black background. imresize does not solve the problem. Thanks.
From: ImageAnalyst on 28 Jul 2010 11:15 Too vague. Not sure what you mean. For example B = A; would seem to fulfill your stated objectives (B will now look exactly like A), but that would seem too trivial and probably not what you're after. You'll have to post your images if you want more specific help.
From: smith Og on 28 Jul 2010 11:44 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <b93e11b3-e592-4eb4-84fd-83655f89b825(a)y11g2000yqm.googlegroups.com>... > Too vague. Not sure what you mean. For example > B = A; > would seem to fulfill your stated objectives (B will now look exactly > like A), but that would seem too trivial and probably not what you're > after. You'll have to post your images if you want more specific > help. Thanks ImageAnalysy That was funny. (B = A). In reality, the white rectangles for either A or B is not perfect, I want to use one to compare to the other. So in a nutshell, I just want the rectangles to preserve the same shape but with a smaller area. For example, say I have a binary image 240 by 240, there is a solid white rectangle in the middle, occupying say 40 by 40 now , how do I make the solid rectangle 20 by 20, preserving the shape, and the remaining part of the image will be a black background. In a similar follow up, if I have a binary image, a solid white rectangle in the middle,and the remaing black backgorund, how do I compute the area of that solid white rectangle, so that I can use in the above paragraph.
From: ImageAnalyst on 28 Jul 2010 11:51 To compute the area in pixels, just use the sum function on your binary image areaInPixels = sum(binaryImage(:)); or you can use bwarea() if you want to go from pixel center to pixel center and computer the area that way instead of by whole pixels. You can put a rectangle there just by a simple assignment, as long as you know the starting and ending rows and columns. If you want to "warp" your image to do a non-linear warp (unlike the linear warping donw by imresize), look into maketform() and tformfwd().
From: Karl on 8 Aug 2010 18:48
I tested for subtracting (- or imsubstract) and dividing (./ or imdivide) on Mac Mini with Mac OSX server running MATLAB 2010a and also on a system with Windows Server 2008 running MATLAB 2010a. I used the code below to iterate for different array types and loop for 50 times to get a good estimate. %Define types of arrays to test types={'double','single','int16','uint16','int8','uint8'}; %Allocate array of time differences tsub=NaN(1,length(types)); tdiv=NaN(1,length(types)); %Number of times to loop for average lt=50; %Outer loop for type for t=1:length(types) %Create images to subtract and divide X = eval([types{t} '(rand(5000))']); Y = eval([types{t} '(rand(5000))']); %Allocate array of times t_Elapsed_Add_simple=NaN(1,lt); t_Elapsed_Add_image=NaN(1,lt); t_Elapsed_Div_simple=NaN(1,lt); t_Elapsed_Div_image=NaN(1,lt); %Inner loop for iterating to get average value for r=1:lt %Test for adding tic Z_Add_simple = X-Y; t_Elapsed_Add_simple(r)=toc; tic Z_Add_image = imsubtract(X,Y); t_Elapsed_Add_image(r)=toc; %Test for dividing tic Z_Div_simple = X./Y; t_Elapsed_Div_simple(r)=toc; tic Z_Div_image = imdivide(X,Y); t_Elapsed_Div_image(r)=toc; clear Z* end tsub(t)=mean(t_Elapsed_Add_simple) - mean(t_Elapsed_Add_image); tdiv(t)=mean(t_Elapsed_Div_simple) - mean(t_Elapsed_Div_image); end The results from the Mac mini are here: tsub = -0.0095 0.0187 0.0090 0.0091 0.0030 0.0040 tdiv = -0.0014 0.1523 -0.0964 0.0135 -0.0915 -0.0413 The results for the Windows box are here: tsub = -0.0255 0.0049 0.2501 0.3544 0.2824 0.3563 tdiv = 0.0006 0.1918 0.5686 0.5532 -0.2713 0.6105 The negative values indicate that - or ./ was faster. The positive values indicate that imsubtract or imdivide was faster. |