bounding-box

Port MATLAB bounding ellipsoid code to Python

浪尽此生 提交于 2019-12-20 12:16:00
问题 MATLAB code exists to find the so-called "minimum volume enclosing ellipsoid" (e.g. here, also here). I'll paste the relevant part for convenience: function [A , c] = MinVolEllipse(P, tolerance) [d N] = size(P); Q = zeros(d+1,N); Q(1:d,:) = P(1:d,1:N); Q(d+1,:) = ones(1,N); count = 1; err = 1; u = (1/N) * ones(N,1); while err > tolerance, X = Q * diag(u) * Q'; M = diag(Q' * inv(X) * Q); [maximum j] = max(M); step_size = (maximum - d -1)/((d+1)*(maximum-1)); new_u = (1 - step_size)*u ; new_u(j

Calculate bounding box of arbitrary pixel-based drawing

蹲街弑〆低调 提交于 2019-12-20 01:09:05
问题 Given a contiguous drawing of arbitrary pixels (e.g. on an HTML5 Canvas) is there any algorithm for finding the axis-aligned bounding box that is more efficient than simply looking at every pixel and recording the min/max x/y values? 回答1: Just scanline from top left to right and down to get y top,and similar algorithm with different directions for the rest. Edit by Phrogz: Here's a pseudo-code implementation. An included optimization ensures that each scan line does not look at pixels covered

Bounding box using MATLAB for the image

强颜欢笑 提交于 2019-12-19 10:04:38
问题 I am trying to draw a bounding box around the white blob in the image below: I did like this: bw = imread('box.jpg'); bw=im2bw(bw); imshow(bw) L = bwlabel(bw); s = regionprops(L, 'Area', 'BoundingBox'); s(1); area_values = [s.Area]; idx = find((100 <= area_values) & (area_values <= 1000)); % list of all the objects %whose area is between 100 and 1000 bw2 = ismember(L, idx); %construct a binary image containing all the objects whose %area is between 100 and 1000 by passing L and idx to

oriented minimum bounding box

折月煮酒 提交于 2019-12-19 04:45:25
问题 I'm looking for a java code to create a oriented minimum bounding box with points, which have a lat/lon value. I've already created a minimum bounding box, like this: public Mbb boundingBox() { Point ll, ur; Mbb bBox; int id =1; ll = new Point(id, Double.MAX_VALUE, Double.MAX_VALUE); ur= new Point(id,-1*Double.MAX_VALUE, -1*Double.MAX_VALUE); if (this.pg.size() <=1) return null; double minLat = Double.MAX_VALUE; double minLong = Double.MAX_VALUE; double maxLat = Double.MAX_VALUE*-1; double

Oriented Bounding Box is Misshapen and the Wrong Size in OpenGL

做~自己de王妃 提交于 2019-12-18 09:38:04
问题 I'm writing a program in OpenGL to load a mesh and draw an oriented bounding box around said mesh. The mesh loads correctly but when I draw the bounding box the box is the wrong shape and far too small. The process I used to calculate this box was to use principle component analysis to find a covariance matrix. I then got the eigenvectors of that matrix and used those as a local co-ordinate system to find the 8 vertices of the cube. Then I calculated a transformation to move the cube from the

OpenGL clipping

假装没事ソ 提交于 2019-12-18 05:06:48
问题 I have been reading articles about clipping now for hours now but I dont seem to find a solution for my problem. This is my scenario: Within an OpenGL ES environment (IOS,Android) I am having a 2D scene graph consisting of drawable objects, forming a tree. Each tree node has its own spatial room with it's own transformation matrix, and each node inherits its coordinate space to its children. Each node has a rectangular bounding box, but these bounding boxes are not axis aligned. This setup

MYSQL Geo Search having distance performance

元气小坏坏 提交于 2019-12-17 22:43:58
问题 I have a mysql select statement for a search on my website which is having performance problems when the site gets really busy. The query below searches for adverts from a table with over 100k records, within 25 miles of the given lat and lon and sorts by distance. The number of miles can differ as it is selected by the user. The problem is that I think it is slow because it does the calculations for all records in the table rather than ones that are within 25 miles of the lat and lon. Is it

Using jQuery to keep scrolling object within visible window

会有一股神秘感。 提交于 2019-12-17 18:11:17
问题 I was in the middle of writing up a long description of what I wanted to do, when I realized that the "How To Ask / Format" sidebar box on this very same "Ask A Question" page does exactly what I want. Basically, it scrolls up and down in unison with the rest of the screen, staying top-aligned with the main section, unless the main section starts to scroll off the top of the visible window. At that point, the sidebar box stops scrolling, and starts to act as if its positioned absolutely,

How to calculate the height of an NSAttributedString with given width in iOS 6 [duplicate]

浪子不回头ぞ 提交于 2019-12-17 15:25:51
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: How to get height for NSAttributedString at a fixed width Now NSAttributedString is available in iOS 6. For layout purposes, I want to know how to calculate the required height of an NSAttributedString under fixed width. I'm looking for something that's equivalent to NSString's - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size but for NSAttributedString. To calculate the drawing size of

Calculate the bounding box's X, Y, Height and Width of a rotated element via JavaScript

做~自己de王妃 提交于 2019-12-17 10:57:33
问题 Basically I'm asking this question for JavaScript: Calculate Bounding box coordinates from a rotated rectangle In this case: iX = Width of rotated (blue) HTML element iY = Height of rotated (blue) HTML element bx = Width of Bounding Box (red) by = Height of Bounding Box (red) x = X coord of Bounding Box (red) y = Y coord of Bounding Box (red) iAngle/t = Angle of rotation of HTML element (blue; not shown but used in code below), FYI: It's 37 degrees in this example (not that it matters for the