cc.exports.LineCollideRect(startLine,endLine,rect)--向量与矩形检测碰撞 --获取矩形的四个顶点位置 local p = {cc.p(rect.x,rect.y),cc.p(rect.x + rect.width,rect.y),cc.p(rect.x+rect.width,rect.y + rect.height),cc.p(rect.x,rect.y+rect.height)} local bRight = PointPosInVector(
建立m文件draw_rectangle.m. 其中p生成矩形的个数 function draw_rectangle(p) t = 1; x = rand(1)*10; y = rand(1)*10; w = rand(1)*10; h = rand(1)*10; b =[x y w h]; rectangle('Position', b) a{t} =b; flag =1; while flag ==1 x = rand(1)*10; y = rand(1)*10; w = rand(1)*10
1. matlab函数bwareaopen──删除小面积对象格式:BW2 = bwareaopen(BW,P,conn)作用:删除二值图像BW中面积小于P的对象,默认情况下使用8邻域.算法:(1)Determine the connected components. L = bwlabeln(BW, conn);(2)Compute the area of each component. S = regionprops(L, 'Area');(3)Remove small objects.