## how to fill color in image in particular area?

I found the Solution with Flood fill algoritham private void FloodFill(Bitmap bmp, Point pt, int targetColor, int replacementColor){ Queue<Point> q = new LinkedList<Point>(); q.add(pt); while (q.size() > 0) { Point n = q.poll(); if (bmp.getPixel(n.x, n.y) != targetColor) continue; Point w = n, e = new Point(n.x + 1, n.y); while ((w.x > 0) && … Read more

## Most efficient way to calculate radial profile

It looks like you could use numpy.bincount here: import numpy as np def radial_profile(data, center): y, x = np.indices((data.shape)) r = np.sqrt((x – center[0])**2 + (y – center[1])**2) r = r.astype(np.int) tbin = np.bincount(r.ravel(), data.ravel()) nr = np.bincount(r.ravel()) radialprofile = tbin / nr return radialprofile

## Equivalent of copyTo in Python OpenCV bindings?

cv::Mat::copyTo does one of two things depending on whether the output matrix has been initialized. If your output matrix is not initialized, using copyTo with a mask creates a new output matrix that is the same type as the input and all of the values are set to 0 over all channels. Once that happens, … Read more

## Connected Component Labeling – Implementation

I’ll first give you the code and then explain it a bit: // direction vectors const int dx[] = {+1, 0, -1, 0}; const int dy[] = {0, +1, 0, -1}; // matrix dimensions int row_count; int col_count; // the input matrix int m[MAX][MAX]; // the labels, 0 means unlabeled int label[MAX][MAX]; void dfs(int x, … Read more

## Fastest available algorithm for distance transform

This paper reviews the known exact distance transform algorithms: “2D Euclidean distance transform algorithms: A comparative survey” https://rfabbri.github.io/stuff/fabbri-EDT-survey-ACMCSurvFeb2008.pdf The fastest exact distance transform is from Meijster: “A General Algorithm for Computing Distance Transforms in Linear Time.” http://fab.cba.mit.edu/classes/S62.12/docs/Meijster_distance.pdf The design of the algorithm is particularly well suited for parallel calculation. This is implemented in my open … Read more

## Rotate bitmap by real angle

tl;dr; Use GDI+ SetWorldTransform With WinAPI’s SetWorldTransform you can transform the space of device context: rotate, shear, offset, and scale. This is done by setting the members of a transform matrix of type XFORM. Fill its members according the documentation. procedure RotateBitmap(Bmp: TBitmap; Rads: Single; AdjustSize: Boolean; BkColor: TColor = clNone); var C: Single; S: … Read more

## Using hierarchy in findContours () in OpenCV?

The hierarchy returned by findContours has the following form: hierarchy[idx][{0,1,2,3}]={next contour (same level), previous contour (same level), child contour, parent contour} CV_RETR_CCOMP, returns a hierarchy of outer contours and holes. This means elements 2 and 3 of hierarchy[idx] have at most one of these not equal to -1: that is, each element has either no … Read more

Categories c++

## Video Stabilization with OpenCV

I can suggest one of the following solutions: Using local high level features: OpenCV includes SURF, so: for each frame, extract SURF features. Then build feature Kd-Tree (also in OpenCV), then match each two consecutive frames to find pairs of corresponding features. Feed those pairs into cvFindHomography to compute the homography between those frames. Warp … Read more

Categories c++

## How do you get the RGB values from a Bitmap on Android?

Bitmap#getPixel(x, y) returns an int with the colour values and alpha value embedded into it. int colour = bitmap.getPixel(x, y); int red = Color.red(colour); int green = Color.green(colour); int blue = Color.blue(colour); int alpha = Color.alpha(colour);

## OpenCV / SURF How to generate a image hash / fingerprint / signature out of the descriptors?

The feature data you mention (position, laplacian, size, orientation, hessian) is insufficient for your purpose (these are actually the less relevant parts of the descriptor if you want to do matching). The data you want to look at are the “descriptors” (the 4th argument): void cvExtractSURF(const CvArr* image, const CvArr* mask, CvSeq** keypoints, CvSeq** descriptors, … Read more