Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
What should I learn to overlap images and counting pixels
Post Flair (click to view more posts with a particular flair)
Post Body

Greetings,

Please refer this link to the images.

I have an image that is my source. I need to duplicate this image and place it nearby, at a particular distance and calculate the total number of pixels. The number of copies is a variable. Distance at which the copies will be place will be calculated by code. The copies placed nearby may or may not overlap the original or other copies.

Source file for this example has 8260 black pixels. when 3 extra copies are made but there is no overlapping, black pixels are 33040 in number. When 3 extra copies are made and they do overlap, the black pixels are 31888 in numbers. In the end, I'm not interested in the final image, I want the pixel count.

My program will perform 8000 of such placements and do the pixel count 8000 times. Hence I need to find a proper and fast way to do it.

Before this, I used to do it another way. Because Octagon, Circle, square are simple figures, and it was just the number of pixels, I used no image at all. Following is a logic I used to count pixels in an octagon.

Area.resize(ArrayRowSize 5, std::vector<int>(ArrayColSize 5, 0));

    for (i = 0; i < NoOfShapesLeftToRight; i  )
    {
        for (j = 0; j < NoOfShapesTopToBottom; j  )
        {
            for (x = A - G; x < A   G; x  )
            {
                for (y = B - G; y < B   G; y  )
                {
                    if ((x - y >= A - B - S - G) && (y <= B   G) && (x   y <= A   B   S   G) && (x <= A   G) && (x - y <= A   G - B   S) && (y >= B - G) && (x   y >= A   B - S - G) && (x >= A - G)) //condition to check bounds of a octagon, equation is easy for circle and not needed for a square.
                    {
                        Area[x][y] = 1;

ArrayRowSize and ArrayColSize are the calculated height and width respectively of the image. NoOfShapesLeftToRight and NoOfShapesTopToBottom are both 2 in the example given above. In the end I used to count number of 1's in array and that's my no of pixels.

In future I have to deal with shapes that do not have specific equations and inputting them as images might be the best idea. Hence I'm looking at a way to do it with overlapping images.

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
16,843
Link Karma
7,126
Comment Karma
9,657
Profile updated: 2 days ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago