Removing Background and Detect shape With C program [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to remove background and detect the shape of the egg from the picture and calculate the oval shape. What would be the best approach for this, I want do it with C.
Thanks in advance.

You can extract exact oval shape by trying following algorithm:
Extract Red Channel from image. It will look as follows:
Apply threshold and suppress all pixel values below 150. It will give you exact oval shape as below:
I have written code for this in C++. Following is the function I used for shape extraction:
int main() {
cv::Mat input = imread("image.jpg");
cv::Mat im_splt[3];
split(input, im_splt);
cv::Mat RedChannel = im_splt[2];
cv::Mat OvalShape = RedChannel > 150;
}

Related

How can I write an array of arraylist in the uml? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
This is my array of arraylist: Arraylist[] a = new Arraylist[SIZE];
I’m struggling with writing it in my UML diagram, how can I write it?
With or without the <>?
The simplest way is to define it this way:
a is of type Arraylist (after the colon) with multiplicity 0..* and its default (after the equal sign) is Arraylist[SIZE].
As commented by #bruno the default value is a bit of interpretation. UML basically should be held language agnostic, but sometimes you just want to point out implementation details (for whatever reason). So you can add the new keyword right in front of the Arraylist[SIZE]. What that actually means is language dependent (and so out of a general scope I like to stick to).

Model 3D spring from points [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have generated points like this and now I what to connect all these points into one model - spring. How can I achieve this? I've tried iterating through each point and build it from polygons or triangles but I have failed.
I have set of rings where each ring was build from points which coords I have.
You probably want to treat these as generalized cylinders and tessellate a triangle mesh. This can be done by sweeping a circle along the path. Some of the details are tricky since undefined tangents can lead to unexpected twists in your triangle mesh. You might want to study the GLE library or the TubeGeometry implementation in ThreeJS.
For simplestic rendering, note that OpenGL has GL_LINE_STRIP. It also has glLineWidth, although many platforms have a max width of 1. You would need to take care to use separate draw calls for seperate springs, otherwise they'll be connected.

How to implement bit error based on percentage in C? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm stuck at trying to simulate an Binary Symmetric Channel in C.
It should work like this: the user enters a number (for example 0.01 = 1%) which represents error rate. So, for instance, if i read 1001 from file every bit has a chance to change its value to 0/1 respectively depending on the entered percent.
Reading from file and writing into another is already working, but I just don't know how to make these percentage-based errors happen.
Any help is much appreciated, thanks in advance.
For generating the percentage-based error, you could do something like this:
double rate = get_rate(); // userinput between 0.0 and 1.0 for 0% - 100%
do {
double nr = drand48(); // Generates a number between 0.0 and 1.0
if (nr < rate) {
// Generate biterror here
}
} while (some_more_bits_to_check);

how to load a stack of images on matlab [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have 170 png images in a folder.
I want to load and store them in a matrix/array/cell array, so that i can easily access and modify them but I'm stuck at the very beginning.
How can I do it? Which is the best structure?
Assuming they are all the same size, in the folder containing the images:
list=dir('*.png'); % read all the .pngs in your folder
Image1=imread(list(1).name); % read the first image to calculate the dimentions of your stack
ImSize=size(Image1)
ImageStack=zeros(ImSize(1),ImSize(2),length(list)); % preallocate your stack with zeros
for ii=1:length(list)
Image=imread(list(ii).name
ImageStack(:,:,ii)=rgb2gray(Image); % copy an image in each step of the third dimsion of your stack
end
If you need the color information just add another dimension to ImageStack and forget the rgb2gray(). Hope that helps!

Camera calibration across multiple images [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Taking one camera and moving it around to take two images of the same object, from a different viewpoint, one should be able to compute a matrix that relates these two scenes. In OpenCV, how is this accomplished?
If said object is a calibration pattern like the chessboard used by OpenCV, then the camera calibration routine mentioned by ChrisO would give you both the camera intrinsics (focal length, principal point, and lens distortion) as well as the camera extrinsics (where they are relatively in space).
If you have general object, then you need to establish a set of 2D correspondences which you can feed into cvFindFundamentalMat. This finds the fundamental matrix which relates the two perspectives. Namely, for each point x in camera 1 and corresponding point x' in camera 2, x'Fx = 0. You can similarly find the epipoles, etc. This uses the 8 point algorithm which requires at least 8 point pairs of point correspondences.
You can get the correspondences either manually or with a robust feature extractor and matcher along the lines of MSER/Affine Harris + SIFT.

Resources