profile
viewpoint
Phil Rukin phil-r @Kittl Berlin, Germany https://rukin.me CTO @Kittl

phil-r/asciifacesbot 24

:smiley: Telegram Bot @asciifacesbot that allows you to append ascii faces to your messages ¯\_(ツ)_/¯

phil-r/awesome-hacker-news 13

:newspaper: More awesome hacker news!

phil-r/designernewsbot 9

:woman_artist: Telegram bot that posts new hot stories from Designer News, shots from Dribbble and projects from Behance to telegram channel

phil-r/awesome-til 5

:notebook: List of awesome TIL (Today I Learned) repos and websites

phil-r/dribbble-top 4

API for most popular dribbble shots

phil-r/deno-advent-2018 2

Completing Advent of Code 2018 using deno

phil-r/adyen-cse-web 1

Client-side encryption on JavaScript

phil-r/awesome-osx 1

:memo: A curated list of awesome applications, softwares, tools and shiny things for OS X.

phil-r/empatika-server-practice 1

Practice makes perfect

hongaar/chaos 0

A social coding experiment that updates its own code democratically.

PullRequestReviewEvent
PullRequestReviewEvent

starteduNetworking/uWebSockets.js

started time in 20 days

Pull request review commentKittl/vectorizing

Handle BG/FG edge cases

 def threshold_simple (img_grayscale):         img_grayscale,         0,         255,-        cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU+        cv2.THRESH_BINARY + cv2.THRESH_OTSU     )[1].astype(np.uint8) -def make_bitmap (img, method):+def threshold (img_grayscale, method):+    if method == 'SIMPLE':+        return threshold_simple(img_grayscale)+    +    return threshold_adaptive(img_grayscale) -    # Grayscale conversion-    if not is_single_channel(img):+def rgba_on_white (img):+    r, g, b, a = cv2.split(img)+    n_alpha = a / 255 -        # If the image is in RGBA format, composite it on top of a white background-        # by combining linearly-        if is_RGBA(img):-            r, g, b, a = cv2.split(img)-            n_alpha = a / 255+    r = (255 * (1 - n_alpha) + r * n_alpha).astype(np.uint8)+    g = (255 * (1 - n_alpha) + g * n_alpha).astype(np.uint8)+    b = (255 * (1 - n_alpha) + b * n_alpha).astype(np.uint8)++    return cv2.merge((r, g, b)) -            r = (255 * (1 - n_alpha) + r * n_alpha).astype(np.uint8)-            g = (255 * (1 - n_alpha) + g * n_alpha).astype(np.uint8)-            b = (255 * (1 - n_alpha) + b * n_alpha).astype(np.uint8)+def invert (img):+    if is_RGBA(img):+        r, g, b, a = cv2.split(img)+        r = 255 - r+        g = 255 - g+        b = 255 - b+        return cv2.merge((r, g, b, a))+    +    return 255 - img -            img = cv2.merge((r, g, b))+def make_bitmap (img, method):+    inverted = invert(img)++    if not is_single_channel(img):+        +        if is_RGBA(img):+            img = rgba_on_white(img)+            inverted = rgba_on_white(inverted)                     -        img_grayscale = cv2.cvtColor(+        # Grayscale conversion+        grayscale = cv2.cvtColor(             img,              cv2.COLOR_RGB2GRAY         ) -    # If image is single channel, no conversion is needed+        inverted_grayscale = cv2.cvtColor(+            inverted,+            cv2.COLOR_RGB2GRAY+        )++        candidates = [grayscale, inverted_grayscale]+         else:-        img_grayscale = img+        candidates = [img, inverted] -    if method == 'SIMPLE':-        thresholded = threshold_simple(img_grayscale)+    candidates = [threshold(img, method) for img in candidates] -    else:-        thresholded = threshold_adaptive(img_grayscale)-    +    bitmap, inverted_bitmap = [+        np.where(candidate == 255, 0, 1).astype(np.uint32) +        for candidate in candidates+    ]++    pixel_count = get_pixel_count(img)+    foreground_area = np.sum(bitmap)+    inverted_foreground_area = np.sum(inverted_bitmap)++    if (foreground_area / pixel_count) < 0.001:

0.001 is not one percent

big-nacho

comment created time in 23 days

Pull request review commentKittl/vectorizing

Handle BG/FG edge cases

 def threshold_simple (img_grayscale):         img_grayscale,         0,         255,-        cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU+        cv2.THRESH_BINARY + cv2.THRESH_OTSU     )[1].astype(np.uint8) -def make_bitmap (img, method):+def threshold (img_grayscale, method):+    if method == 'SIMPLE':+        return threshold_simple(img_grayscale)+    +    return threshold_adaptive(img_grayscale) -    # Grayscale conversion-    if not is_single_channel(img):+def rgba_on_white (img):+    r, g, b, a = cv2.split(img)+    n_alpha = a / 255 -        # If the image is in RGBA format, composite it on top of a white background-        # by combining linearly-        if is_RGBA(img):-            r, g, b, a = cv2.split(img)-            n_alpha = a / 255+    r = (255 * (1 - n_alpha) + r * n_alpha).astype(np.uint8)+    g = (255 * (1 - n_alpha) + g * n_alpha).astype(np.uint8)+    b = (255 * (1 - n_alpha) + b * n_alpha).astype(np.uint8)++    return cv2.merge((r, g, b)) -            r = (255 * (1 - n_alpha) + r * n_alpha).astype(np.uint8)-            g = (255 * (1 - n_alpha) + g * n_alpha).astype(np.uint8)-            b = (255 * (1 - n_alpha) + b * n_alpha).astype(np.uint8)+def invert (img):+    if is_RGBA(img):+        r, g, b, a = cv2.split(img)+        r = 255 - r+        g = 255 - g+        b = 255 - b+        return cv2.merge((r, g, b, a))+    +    return 255 - img -            img = cv2.merge((r, g, b))+def make_bitmap (img, method):+    inverted = invert(img)++    if not is_single_channel(img):+        +        if is_RGBA(img):+            img = rgba_on_white(img)+            inverted = rgba_on_white(inverted)                     -        img_grayscale = cv2.cvtColor(+        # Grayscale conversion+        grayscale = cv2.cvtColor(             img,              cv2.COLOR_RGB2GRAY         ) -    # If image is single channel, no conversion is needed+        inverted_grayscale = cv2.cvtColor(+            inverted,+            cv2.COLOR_RGB2GRAY+        )++        candidates = [grayscale, inverted_grayscale]+         else:-        img_grayscale = img+        candidates = [img, inverted] -    if method == 'SIMPLE':-        thresholded = threshold_simple(img_grayscale)+    candidates = [threshold(img, method) for img in candidates] -    else:-        thresholded = threshold_adaptive(img_grayscale)-    +    bitmap, inverted_bitmap = [+        np.where(candidate == 255, 0, 1).astype(np.uint32) +        for candidate in candidates+    ]++    pixel_count = get_pixel_count(img)+    foreground_area = np.sum(bitmap)+    inverted_foreground_area = np.sum(inverted_bitmap)++    if (foreground_area / pixel_count) < 0.001:+        # If total area of the foreground is less than 1 percent of the image's++        # It's possible that the inverted image produced a better bitmap.+        # The main relevant case is an all-or-mostly white foreground with a transparent background.++        #NOTE: The inverted bitmap CAN be worse than the non-inverted one.+        # e.g A very small amount of black pixels on a transparent background++        if inverted_foreground_area > foreground_area:+            # Then the inverted bitmap is better. And its area is at least 1.

1 what? pixel?

big-nacho

comment created time in 23 days

PullRequestReviewEvent
PullRequestReviewEvent

startedjafarlihi/core86

started time in a month

startedmodularml/mojo

started time in a month

startedyisibl/resvg-js

started time in a month

PR closed Kittl/vectorizing

Release
+42 -25

0 comment

3 changed files

phil-r

pr closed time in 2 months

PR opened Kittl/vectorizing

Release
+42 -25

0 comment

3 changed files

pr created time in 2 months

PullRequestReviewEvent
PullRequestReviewEvent

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha e94928809eeddc6ab672e930fa5d0269baec53d0

Add npm badge

view details

push time in 2 months

release phil-r/awesome-hacker-news

v1.0.9

released time in 2 months

created tagphil-r/awesome-hacker-news

tagv1.0.9

:newspaper: More awesome hacker news!

created time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha e57c37af0867ab8383e76660e3cd3936aae97633

Move more dead projects to the graveyard

view details

Phil Rukin

commit sha 78a7f944b239ee3bc1c1109faa4dce6579dc8f72

1.0.9

view details

push time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha fb0dcfb4e9b0185245d32fa098404a012233639b

Re-generate readme

view details

push time in 2 months

release phil-r/awesome-hacker-news

v1.0.8

released time in 2 months

created tagphil-r/awesome-hacker-news

tagv1.0.8

:newspaper: More awesome hacker news!

created time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha 294351ba8a436305dfcf266a00edd8b4f81ed89d

Add Hacki mobile app

view details

Phil Rukin

commit sha 5997ce81670664dcc9026b6059fbbe750b63fbbf

1.0.8

view details

push time in 2 months

release phil-r/awesome-hacker-news

v1.0.7

released time in 2 months

created tagphil-r/awesome-hacker-news

tagv1.0.7

:newspaper: More awesome hacker news!

created time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha 38b804ecda88f6b9845332e1a8378206d78c34f9

Move some dead projects to the graveyard

view details

Phil Rukin

commit sha 92a3d77bea7b5144bbd520807daa810ae40bb1ac

1.0.7

view details

push time in 2 months

release phil-r/awesome-hacker-news

v1.0.6

released time in 2 months

created tagphil-r/awesome-hacker-news

tagv1.0.6

:newspaper: More awesome hacker news!

created time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha 650c4e9bc84fe84a6e738544b9f66c4286dd09ee

Add test script placeholder

view details

Phil Rukin

commit sha 7cfc72a397e3823faf0b752b064dc3c3c20d5a5d

1.0.6

view details

push time in 2 months

PR closed phil-r/awesome-hacker-news

Add a few Telegram channel/bot

cc authors: @Mevaser @ylogx @yegle 🎉

+4 -0

0 comment

1 changed file

PeterDaveHello

pr closed time in 2 months

push eventphil-r/awesome-hacker-news

Phil Rukin

commit sha 59a835a56e062d91d133355e637f03674c7a9d1f

Add new sources, closes #3

view details

push time in 2 months

more