Results for bwtraceboundary translation from English to Chinese (Simplified)

Computer translation

Trying to learn how to translate from the human translation examples.

English

Chinese

Info

English

bwtraceboundary

Chinese

 

From: Machine Translation
Suggest a better translation
Quality:

Human contributions

From professional translators, enterprises, web pages and freely available translation repositories.

Add a translation

English

Chinese (Simplified)

Info

English

(matlab帮助内容) measuring angle of intersection a common task in machine vision applications is hands-free measurement using image acquisition and image processing techniques. your goal is to measure the angle and point of intersection between two beams using bwtraceboundary, which is a boundary tracing routine. contents step 1: load image step 2: extract the region of interest step 3: threshold the image step 4: find initial point on each boundary step 5: trace the boundaries step 6: fit lines to the boundaries step 7: find the angle of intersection step 8: find the point of intersection step 9: plot the results. step 1: load image read in gantrycrane.jpg and draw arrows pointing to two beams of interest. it is an image of a gantry crane used to assemble a bridge. rgb = imread('gantrycrane.png'); imshow(rgb); text(size(rgb,2),size(rgb,1) 15,'image courtesy of jeff mather',... 'fontsize',7,'horizontalalignment','right'); line([300 328],[85 103],'color',[1 1 0]); line([268 255],[85 140],'color',[1 1 0]); text(150,72,'measure the angle between these beams','color','y',... 'fontweight', 'bold'); step 2: extract the region of interest crop the image to obtain only the beams of the gantry crane chosen earlier. this step will make it easier to extract the edges of the two metal beams. % you can obtain the coordinates of the rectangular region using % pixel information displayed by imtool start_row = 34; start_col = 208; croprgb = rgb(start_row:163, start_col:400, :); imshow(croprgb) % store (x,y) offsets for later use; subtract 1 so that each offset will % correspond to the last pixel before the region of interest offsetx = start_col-1; offsety = start_row-1; step 3: threshold the image convert the image to black and white for subsequent extraction of the edge coordinates using bwtraceboundary routine. i = rgb2gray(croprgb); threshold = graythresh(i); bw = im2bw(i,threshold); bw = ~bw; % complement the image (objects of interest must be white) imshow(bw) step 4: find initial point on each boundary the bwtraceboundary routine requires that you specify a single point on a boundary. this point is used as the starting location for the boundary tracing process. to extract the edge of the lower beam, pick a column in the image and inspect it until a transition from a background pixel to the object pixel occurs. store this location for later use in bwtraceboundary routine. repeat this procedure for the other beam, but this time tracing horizontally. dim = size(bw); % horizontal beam col1 = 4; row1 = min(find(bw(:,col1))); % angled beam row2 = 12; col2 = min(find(bw(row2,:))); step 5: trace the boundaries the bwtraceboundary routine is used to extract (x, y) locations of the boundary points. in order to maximize the accuracy of the angle and point of intersection calculations, it is important to extract as many points belonging to the beam edges as possible. you should determine the number of points experimentally. since the initial point for the horizontal bar was obtained by scanning from north to south, it is safest to set the initial search step to point towards the outside of the object, i.e. 'north'. boundary1 = bwtraceboundary(bw, [row1, col1], 'n', 8, 70); % set the search direction to counterclockwise, in order to trace downward. boundary2 = bwtraceboundary(bw, [row2, col2], 'e', 8, 90,'counter'); imshow(rgb); hold on; % apply offsets in order to draw in the original image plot(offsetx boundary1(:,2),offsety boundary1(:,1),'g','linewidth',2); plot(offsetx boundary2(:,2),offsety boundary2(:,1),'g','linewidth',2); step 6: fit lines to the boundaries although (x,y) coordinates pairs were obtained in the previous step, not all of the points lie exactly on a line. which ones should be used to compute the angle and point of intersection? assuming that all of the acquired points are equally important, fit lines to the boundary pixel locations. the equation for a line is y = [x 1]*[a; b]. you can solve for parameters 'a' and 'b' in the least-squares sense by using polyfit. ab1 = polyfit(boundary1(:,2), boundary1(:,1), 1); ab2 = polyfit(boundary2(:,2), boundary2(:,1), 1); step 7: find the angle of intersection use the dot product to find the angle. vect1 = [1 ab1(1)]; % create a vector based on the line equation vect2 = [1 ab2(1)]; dp = dot(vect1, vect2); % compute vector lengths length1 = sqrt(sum(vect1.^2)); length2 = sqrt(sum(vect2.^2)); % obtain the larger angle of intersection in degrees angle = 180-acos(dp/(length1*length2))*180/pi angle = 129.4971 step 8: find the point of intersection solve the system of two equations in order to obtain (x,y) coordinates of the intersection point. intersection = [1 ,-ab1(1); 1, -ab2(1)] \ [ab1(2); ab2(2)]; % apply offsets in order to compute the location in the original, % i.e. not cropped, image. intersection = intersection [offsety; offsetx] intersection = 143.0917 295.7494 step 9: plot the results. inter_x = intersection(2); inter_y = intersection(1); % draw an x at the point of intersection plot(inter_x,inter_y,'yx','linewidth',2); text(inter_x-60, inter_y-30, [sprintf('%1.3f',angle),'{\circ}'],... 'color','y','fontsize',14,'fontweight','bold'); interstring = sprintf('(%2.1f,%2.1f)', inter_x, inter_y); text(inter_x-10, inter_y 20, interstring,... 'color','y','fontsize',14,'fontweight','bold'); copyright 1993-2005 the mathworks, inc. published with matlab® 7.8 matlab and simulink are registered trademarks of the mathworks, inc. please see www.mathworks.com/trademarks for a list of other trademarks owned by the mathworks, inc. other product or brand names are trademarks or registered trademarks of

Chinese (Simplified)

syries(matlab的帮助内容)

Last Update: 2011-04-08
Usage Frequency: 1
Quality:

Get a better translation with
7,745,695,564 human contributions

Users are now asking for help:



We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies. Learn more. OK