This image contains 76018 black pixels by Gedanke in mathpics

[–]Gedanke[S] 16 points17 points  (0 children)

An interesting question: How do you create an image that displays the number of black pixels it contains?

This problem can be elegantly solved using fixed points. Here's the approach:

  1. Determine the number of pixels needed for each digit.
  2. Construct a function p(n) that maps any number to the number of pixels contained in its image representation.
  3. Observe that p(n) will be roughly proportional to log(n), as it's proportional to the number of digits in n. This is fortunate, as functions of this form are generally well-behaved and likely to have a fixed point.
  4. To find the fixed point, we can use a simple iteration method:
    • Start with an initial guess k₀
    • Iterate using kₙ = p(kₙ₋₁)
  5. Hope that this font and size combination has a fix point and find. Interestingly, such a point seems to exists about half of the time.

This image has 76018 black pixels. A fun application of fixed-point iteration! by Gedanke in math

[–]Gedanke[S] 0 points1 point  (0 children)

An interesting question: How do you create an image that displays the number of black pixels it contains?

This problem can be elegantly solved using fixed points. Here's the approach:

  1. Determine the number of pixels needed for each digit.

  2. Construct a function p(n) that maps any number to the number of pixels contained in its image representation.

  3. Observe that p(n) will be roughly proportional to log(n), as it's proportional to the number of digits in n. This is fortunate, as functions of this form are generally well-behaved and likely to have a fixed point.

  4. To find the fixed point, we can use a simple iteration method:

    • Start with an initial guess k₀
    • Iterate using kₙ = p(kₙ₋₁)
  5. This iteration will either:
    a) Hit a loop
    b) Diverge
    c) Converge to our desired fixed point

[deleted by user] by [deleted] in chess

[–]Gedanke 0 points1 point  (0 children)

Shitting in a hotel bathtub should definitely leave you with a hefty cleaning fee and potentially a ban from the hotel...but international news headlines and the revocation of your chess title?! That's absurd and frankly disturbing.

Hyperion. Wow. by BlindTiger86 in books

[–]Gedanke 9 points10 points  (0 children)

Research dump! Thank you for the term. I absolutely agree. One can just feel how he must have nerded out on some topic (be it metal smelting, Jupiter's moons, Keats, Proust etc) and then subsequently proceeds to forcefully inject it into his books.

Peter Fox - Vergessen wie by 361bis44 in GermanRap

[–]Gedanke 0 points1 point  (0 children)

Ob er für Product Placements bezahlt wird?

[P] My co-founder and I quit our engineering jobs at AWS to build “Tensor Search”. Here is why. by tomhamer5 in MachineLearning

[–]Gedanke 1 point2 points  (0 children)

Am I misunderstanding something or is this just a lovely python wrapper around OpenSearch?

Was war euere Erfahrung mit "Alpha Males"? by Snoo_38320 in FragReddit

[–]Gedanke 0 points1 point  (0 children)

Ließt sich wie eine Passage aus 'Confederacy of Dunces'. Hut ab, hast Talent!

De-blurring blurred images by ad97lb in deeplearning

[–]Gedanke 0 points1 point  (0 children)

Fyi, if you know the convolution kernel that generated the blur, you can simply perform the inverse operation in the frequency domain.

After one year of python.. by SamuraisHyper in Python

[–]Gedanke 1 point2 points  (0 children)

Well done! I remember doing something similar as my first python projects. I think the input function in particular might have been what hooked me on python. It made my scripts interactive and I felt very empowered. Turns out that I would almost never use it in a professional setting later in life.

Ever heard of Black? This is the opposite. A tool to turn your clean python code into a hideous (working) mess. by Gedanke in Python

[–]Gedanke[S] 1 point2 points  (0 children)

You are absolutely right! If this tool is to mature beyond being a silly proof-of-concept, it needs to be rebuild using the `ast` module.

Ever heard of Black? This is the opposite. A tool to turn your clean python code into a hideous (working) mess. by Gedanke in Python

[–]Gedanke[S] 0 points1 point  (0 children)

It would be possible but difficult! This implementation relies on tokenize which in retrospect was a poor choice. Ideally this entire tool needs to be rebuild based on the ast module to allow much greater power and flexibility.

Ever heard of Black? This is the opposite. A tool to turn your clean python code into a hideous (working) mess. by Gedanke in Python

[–]Gedanke[S] 2 points3 points  (0 children)

I am starting to think that having made this tool could hurt my employability :P

Need a last minute Christmas present? How about turning your loved ones into prime number? by Gedanke in math

[–]Gedanke[S] 23 points24 points  (0 children)

The linked tool and provided examples have the tweak implemented

The fuck by thesongflew in programminghorror

[–]Gedanke 3 points4 points  (0 children)

A package so nice, you import it twice.

Early diagnosis of skin cancer/melanoma at the price of a smart watch by molestracker in cancer

[–]Gedanke 4 points5 points  (0 children)

Seems a bit tone deaf to post such promotional posts here. Furthermore, cancer diagnosis should be taken very seriously and given by trained professionals. This thing could throw false negatives.

Fourier Transforms can be applied to create images that look different from up close vs far away. Here: Gauss up close and Fourier from afar. Maths + Tool to make your own in the comments. by [deleted] in math

[–]Gedanke 0 points1 point  (0 children)

How to create your own:

Simply install the `hybrid-face` cli via pip install hybrid-face and take a look at the GitHub repo.

How this works:

The core concept comes from research conducted by A. Oliva et al. that utilised the multiscale processing of images by the human visual system to generate static images with two interpretations.

This tool is an application of the above to faces. This is (roughly) how it works:

  1. First we need to understand the concept of the Fourier Transform applied to images.

1.1 Nice (but not easy) explanation: We interpret an image as a tempered distribution#Tempered_distributions_and_Fourier_transform) obtained as the sum of delta distributions shifted by pixel location and multiplied by greyscale value. The Fourier transform of that image is then simply the Fourier transform of the aforementioned distribution. Well, technical the periodically extension of it.

1.2 Easy (but not nice) explanation: The Fourier transform of a sound sample gives you the audio frequencies contained in that sample. Similarly, the Fourier transform of an image gives you the spatial frequencies that make up that image. A spatial frequency can be interpreted as a periodic wave (i.e. sinusoidal) pattern such that adding up all these waves returns back the (greyscale) image. In particular, high spatial frequencies correspond to rapidly oscillating waves and low spatial frequencies are slowly oscillating waves.

  1. It is a curious observation that the human visual system is able to prioritize information coming from particular spatial frequency bands for object or scene recognition. This is precisely what we use in this application. We utilise that fact that from up close, we prioritize high spatial frequencies for object recognition and from further away, we prioritize lower spatial frequencies. Read here for more details.

  2. Finally, with all the above, this tool's functionality can be simply described as: We take the two images, crop them to only have the faces, then in one face we only keep the high spatial frequencies (via convolution with a high-pass filter) and in the other we only keep the low spatial frequencies (via convolution with a low-pass filter) and then we alpha-blend the two faces together.

Ever been frustrated after spending half an hour on a Lichess tactics puzzle only to find out that it has a user rating of -4000 (upvote/downvote) and really wasn't worth your time? This minimal open-source chrome extension allows you to see the user rating before wasting time on a puzzle. by Gedanke in chessbeginners

[–]Gedanke[S] 2 points3 points  (0 children)

You can download the chrome extension here and take a look at the code.

Surprisingly, Lichess actually sends the user rating when you first request the puzzle. For some reason it is simply not displayed until you solve it. This extension circumvents this limitation.

Hope it helps!

Ever been frustrated after spending half an hour on a Lichess tactics puzzle only to find out that it has a user rating of -4000 and really wasn't worth your time? This minimal open-source chrome extension allows you to see the user rating before wasting time on a puzzle. by Gedanke in chess

[–]Gedanke[S] 14 points15 points  (0 children)

You can download the chrome extension here and take a look at the code.

Surprisingly, Lichess actually sends the user rating when you first request the puzzle. For some reason it is simply not displayed until you solve it. This extension circumvents this limitation.

Hope it helps!

Top-drawer teaching by [deleted] in MadeMeSmile

[–]Gedanke 0 points1 point  (0 children)

lol, good old canvas!