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
Hey I was trying solve this problem . Where you're asked to segment out "zebra" out of image. Below is the given image.
And output should be like this.
Well I got stuck at "strips" of zebra cause they may get segmented as separate objects.
In image processing, it is important to look at your image and try to understand the difference between your region of interest, i.e. the zebra, and the rest, i.e. background.
In this example, a clear difference is that the background is rather greenish and the zebra black and white. Therefore, the green channel of the image can be used to extract the background. Afterwards the result can be (non-linearly) cleaned up using some dilation and erosion steps.
A simple and non-perfect segmentation technique is (in Matlab):
I = imread('lA196m.jpg');
% plot the original image
figure
subplot(2,2,1)
imshow(I)
% calculate the green channel (relative green value)
greenChannel = double(I(:,:, 2))./mean(I(:,:,:), 3);
binary = greenChannel > 1; % apply a thresshold
subplot(2,2,2)
imshow(binary);
% remove false positives (backgrounds)
se1 = strel('sphere',20);
binary2 = imdilate(imerode(binary,se1), se1);
subplot(2,2,3)
imshow(binary2);
% add false negatives
se2 = strel('sphere',10);
binary3 = imerode(imdilate(binary2,se2), se2);
subplot(2,2,4)
imshow(binary3);
% calculate & plot the boundary on the original image
subplot(2,2,1)
Bs = bwboundaries(~binary3);
B = Bs{1};
hold on
plot(B(:, 2), B(:, 1), 'LineWidth', 2);
Related
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 2 years ago.
Improve this question
Need to draw a custom world map drawing either the complete world map or a certain region. Also highlighting different regions with different colours.
I have tried https://github.com/KiloKilo/WorldMatrix. I am able to colour the regions but unable to draw custom regions and provide custom colour to certain regions. Unable to find any other library.
Using below code, it shows nothing
let generator = WorldMatrixGenerator()
// Set the number of columns per rows (Default: 100)
generator.columns = 20
// Set your desired map cutting (Default: .world)
// use .custom(north, east, south, west) for a custom bounding
generator.mapCutting = .europe
// Set the output type (.enum, .ascii, .emoji) (Default: .enum)
generator.exportType = .enum
// Generates the world array
generator.generate()
Basically want to achieve the one in the image. Can someone let me know how can draw custom regions?
Thanks for the help in advance.
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
My task is recognition a lightning on the picture. I have chosen to use OpenCV.
I'm using binary tresholding to get image like this.
Original:
After binary thresholding:
How now to determine whether there is lightning in the image?
So, how to distinguish lightning on the image from other lines? For example
on this image after binary tresholding i have got the following:
but if i just count the number of white pixels - i get a wrong answer.
Main part of my code:
if ((Igray = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE)) == 0) {
return -1;
}
int block_size = atoi(argv[2]);
double offset = (double)atof(argv[3]);
Iat = cvCreateImage(cvSize(Igray -> width, Igray -> height), IPL_DEPTH_8U, 1);
// treshold
cvThreshold(Igray, Iat, offset, 255, CV_THRESH_BINARY);
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 am working on a project where i need a reference image like this
say if want to create a image using Opencv with particular -width -hight
and certain number for horizontal(x) & vertical(y) line to be created evenly
You can create an image of a particular size using the Mat constructor:
cv::Mat::Mat ( Size size, int type )
This is an overloaded member function, provided for convenience. It
differs from the above function only in what argument(s) it accepts.
Parameters
size 2D array size: Size(cols, rows) . In the Size() constructor, the number of rows and the number of columns go in the reverse order.
type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to
CV_CN_MAX channels) matrices.
and you can draw lines on images (Mats) using the line method:
C++: void line(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Some example code to create an image with a line in would be:
cv::Mat myImage=cv::Mat::zeros(cv::Size(10,10), CV_8UC1);
line(myImage, cv::Point(5,5), cv::point(10,10), cv::Scalar::all(255));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on visualization tree map which shows the product categories.There are two values of any range.First value decides size of segments and second value decides the color of segments.Now the conditions is if value is +ve then color range must be vary between green color and if -ve then value vary between red color (for big value color effect will be more dark and for small value color effect will be more light )
How do I done this .
the value ranges between 12 to 8 digits (- or +ve)
Help me please.
You would want start by looking at the colorWithHue:saturation:brightness:alpha: method of UIColor. The hue value will control choice between greens and reds. The saturation and/or brightness value will determine the "darkness", depending on what exactly you mean by "dark".
You can create a simple app with a UISliders for hue/sat/brightness and a UIView to display the selected color to experiment with HSB colors. Here's a gist that implements such a tool.
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 4 years ago.
Improve this question
I am making a top down, rpg-type game - similar to Pokemon, but I am stuck at character movement. Basically, what I want to achieve is a smooth tile based movement system for my player and other people on the map. Has anyone managed to do this effectively? If so, how?
If you are using a grid system, like Pokémon uses, you might be able to achieve this by setting a speed at which they can move between tiles.
For example, if you made it so that they can move one tile a second, you can then use (float)gameTime.ElapsedGameTime.TotalSeconds in your Update function to determine how quickly the game is updating. From this, you should be able to make it so that the character moves ((float)gameTime.ElapsedGameTime.TotalSeconds * TileSize) each update.
This would mean that if they have 4 updates a second (very slow, but for example), they would move 1/4 of the distance across the tile every update, and reach the end point by the end of the movement time period (1 second in this case). In this situation, if you had 32 pixel tiles, they would move 0.25 * 32 every update, or 8 pixels.
Hope this helps.
The 'technical' word for what you want is probably 'interpolation'.
I think the simplest thing you want to do is interpolate the unit position between its starting point (the middle of starting tile) and its ending point (the middle of ending tile) in the time period you want to give it a smooth movement.
Formula goes something like this:
float k = timeSinceStarted / durationOfMovement;
pos.X = startPos.X + (endPos.X - startPos.X) * k;
pos.Y = startPos.Y + (endPos.Y - startPos.Y) * k;
In a game, it's probably better to pre-compute the delta, and add increments instead of storing start position. Something like this (Note: I haven't double checked this computation).
delta = endPos - startPos;
position += delta * (timeSinceLastUpdate / durationOfMovement);