A simple algorithm to find the number of all possible sections in artworks(or anything rectangular and 2D that can be represented by pixel dimensions) that maintain their styles and don't compromise their essences as long as they have a minimum size of axb or bxa pixels.
- Table of Contents
- General Info
- Technologies
- Setup
- Features
- Status
- Inspiration
- Version
- Contributors
- Licence & Copyright
- height x width
- (mh) minHeight x minWidth (mw)
⇒ Let's say y = height + 1 and x = width + 1
⇒ For the first line, we use the distributive property for (y - mh):
Formula1: Let a and b be integers, with b ≥ a. There are (b - a + 1) integers in the interval [a, b].
To find the number of occurrences of x, we consider the expressions (x - (mw)) and (x - (mw + width - mw)) from the first line. The pattern (x - (mw)), (x - (mw + 1)), (x - (mw + 2)), ...,(x - (mw + width - mw)) emerges from this. Subtracting x from this pattern gives us the remaining values, which we can use to determine how many times x occurs. In this case, we obtain the pattern mw, mw + 1, mw + 2, ..., mw + width - mw. We know that (mw + width - mw), so the value of width, is greater than or equal to mw. According to the Formula1, there are ((mw + width - mw) - (mw) + 1) x. So, there are (width - mw +1) x.
After calculating the value of x, we need to calculate the sum of all numbers subtracted from x.
If we use the pattern mw, mw + 1, mw + 2, ..., mw + width - mw, we can see that there are mw in the range [mw, width] equal to the number of integers. In other words, according to the Formula1 there are (width - mw + 1) mw.
Finally, we need to sum the remaining numbers in our hands.
Formula2: Let b be integers, with b ≥ 1. The sum of all integers in the interval [1, b] is (b.(b+1)/2).
Let's consider the pattern (x-mw), (x-(mw+1)), (x-(mw+2)), ...,(x-(mw + width - mw)). We calculated how many x and mw numbers are. When we subtract x from the pattern, we are left with mw, mw + 1, mw + 2, ..., mw + width - mw. After subtracting mw as well, we have 0, 1, 2, ..., width - mw remaining in our hands. Therefore, we need to sum all integers in the range [0, width - mw]. According to the Formula2, the sum of these numbers is ((width - mw)(width - mw + 1) / 2).
⇒ We use the distributive property for the last expression:
⇒ We said x = width + 1.
⇒ The last statement is the simplest form of the first line. Let's apply the simplification to the entire expression.
⇒ For the first line, we use the distributive property again for ((width - mw + 1)x(width - mw + 2) / 2).
⇒ Actually the same situation as we first calculated.
was equal to
So in the above operation is equal to
⇒ Thanks to this formula, we can calculate the sections with a minimum pixel size of minWidthxminHeight size. However, the pixel sizes of this table can be changed place, which means that minWidth can be equal to minHeight, and minHeight can be equal to minWidth. That is, width changes place with height. If the minimum pixel size is axb initially, in widthxheight format, it can also be bxa. Therefore, we need to find the number of unions of the clusters obtained from these two minimum pixel sizes.
If a < b <= width:
If b < a <= height :
If a = b:
- (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
- Visual Studio Vode version 1.80.0
- Arbitrary-sized integer class for C++ (aka BigInt class) by Syed Faheel Ahmad
- Download, compile, and run.
- It is a console/command-line application.
- It is recommended not to change the file hierarchy. If you are going to modify the file hierarchy, make sure to correctly adjust the paths of all included header files.
Finds all possible sections with minimum axb pixel size in anything 2D and rectangular that can be represented by pixel dimensions. It also includes the minimum bxa pixel dimensions in the calculation. Returns the result as (cardinality of the set axb) + (cardinality of the set bxa) - (cardinality of intersection of axb set and bxa set). However, it also has methods to calculate sections specifically for axb or bxa pixel sizes.
Although the algorithm may seem related to artworks, the phrase "art" there is just a reference to where the inspiration comes from. You can find more information in the inspiration section.
With the exception of bug fixes (if any), development of this project is complete.
https://twitter.com/EjderAysunn/status/1674883836935561217
While examining the masterpiece below, I noticed that regardless of where I take a section at least 480x270 or 270x480 pixel size (this minimum reference size can be larger or smaller according to your preference), each section maintained its style and did not compromise its essence. In other words, every piece extracted from this masterpiece, meeting the minimum size requirement, was without exception a masterpiece in itself. This led me to wonder how many masterpieces were hidden within this masterpiece, prompting me to conduct this study.
Version 1.0.0
Ejder Aysun ejderaysunn@gmail.com
BigInt Project by Syed Faheel Ahmad
The BigInt project is protected by the MIT license and is developed by Syed Faheel Ahmad. In this project, I have used certain parts of the BigInt project, modified some parts according to this project, removed certain parts, and left some parts usable, which could assist in modifying the algorithm in this project or contribute to the contributors of this project. The modified sections are indicated within the respective files. If you need more than what is available in this repository to contribute to this project or if you want to learn more about the BigInt project and contribute to it, you can review the project through this link: https://github.com/faheel/BigInt.
© Ejder Aysun, Algorithm for Counting All Possible Sections that Have a Min Pixel Size of axb and bxa in Artworks
Licensed under the MIT Licence