Note: The code can be found here: quitPusheenMeAround

I love Pusheen, and I’m also a fan of playing around in my terminal. After talking to someone the other day, I was inspired to work on this; she mentioned how an officemate commented on the Pusheen that popped up whenever she opened her shell.

I didn’t use any statistics other than the standard deviation for a small portion of the image segmentation (cat v. background). Having said that, I think that this is a fun exercise to occupy my time.

Initial Problem

A quick Google search revealed about 3 Pusheen ASCII art images online, which is disappointing given how many Pusheen images and GIFs there are. After a long week at work and some climbing earlier today, I’m ready to spend this Friday night in. So, it looks like I’m making a Pusheen ASCII art converter and some shell scripts. Also, Pusheen sounds like pushin’, which opens up several cute GitHub project names.


Process

1) Create a folder wherein we will store many Pusheen images.

2) Load, resize, and convert those images to ASCII art.

3) Make some shell scripts

4) Push the code.

Immediate problems

                                  }}
               }|))|)           ))   |
              )      )         )  xX   }
             | uhMMoQ )}     }| Q#WWWk  |}}))||||||||||||||)}}
            / O&8oaW%h         d%Whbo%Mc                      )|)}
           / w%Wdpdpo%MY|/)/jxo%*pdbpb8&0XQZwdbkhaaaaaaakbpZCj    |)
    }}}}} ) m%Mpbbbbpk8&WWWWW&8apbbbbddW8W&WWWM8888888W#88888W#hZ/  |)
         } J8Wpbbbbbbpa8#o8*o8opbbbbbbddkbdpqqwhMWWWW#dp#WMWW&8W&&oQ  |
   vCLCUzrtW8bdbbbddbbbabbhbbakbbbdbbbbbddbhao**M#ooabbbk#WWWMapdaW8#Q  )        }||||}
 ) b&WMMMMW%adbbbdbbdbdpppahppdbbdbddbbbd#&WWMM##hpddbbbddkhkbdbbdpkW%a/ )      )      }
     rUOmd%Wpbbbd#88*ddo&o%&*&hddM88adbbdoM****oohbbbbbbbbddddbbbbbdpa%WJ )    | vdoadv }
 ) wWWWWM&%hdbbbd*88*dbkMB&8B#bbdM8&adbbdoWMMMMMW#dbbbbbbbbbbbbbbbbbbdd&8C ) }/ m8%88%&U})
 } CqLc)r&Wpbbbbbdbbdbbdd*WMopbbbdbddbbbbdpppppppdbbbbbbbbbbbbbbbbbbbbdd8&u|/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ddbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbpM%Z )
        ) Q&8hpdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbpdW%w |
         | u*%Whppdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbdpd*8WQ |
          )  0*8&obbdpppppppppdbdpppppppppppppppppdbdppppppppppdbb*&&b  |
           }|  YkB#waWWWWWWWWMopk#MMMMMMMMWWWWWWMMophMMWWWWWWWW*qaBa|  )
             )/  &8*%Wwqqqppp&%kMBhdbdddddddddddd88bW%bdppqqqwMBoMBO j
               ))Jh*ku       LMWWk               mMWWp        ch##p|)
                      |)|||)|  j  )||||||||||||||  x  /|||||)|
                 }|||}       })  |               )}  )        }|)||
                               }                   }

looks FAR better than

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@$$$@@M*#oa@@@@@@@$@@$$$@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$@$BB@@$$@@$W*#q**o@$$$$$$$$@8MMW%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$@@8b*#&B@$$WaWppw##W8B&B@@@B&M*aMa8$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$@B&###*%%aMbqppq#&*MMWM&M&#hpmh#*@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$@%8BBBW##MWkqdppqk*d*MkW#aapqpppM#B$$$$$@$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$@@@Wo**#W8hMMdqpwqpppqpdpqbpqqppppwooM@%%B$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$@$B8%&W#*W*qppb#opppqqpppqppqppp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$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$W#oph*###*hbwOZqdka**oMWppppppppppppppppmo##@@$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$@B8hwqwqppka*##obpqZ0Om0M*wpppppppppppppk*MWM@$$$$@@$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$&Whqpppppqqwqba**##*oo*#bqppppppppppppp#WW&8@$@@$$$@$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$&Wkqpppppppppqqwqqdkhkkqqppppppppppppppk**Wo%$$$@BB$@$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$8Wkqpppppppppppppppqqqqppppppppppppppppqqq#*%$@&WW#&$@$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$8WkqppppppppppppppppppppppppppppppppppppppM*%$Mh&W&*%@@$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$&WaqppppppppppppppppppppppppppppppppppppqbWW@@#Wka&*%$@$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$#**wppppppppppppppppppppppppppppppppppppwo##@#MWdooo$@$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$@$%aMqpppppppppppppppppppppppppppppppppppppMM&##M#&Wh%@@$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$@@**omppppppppppppppppppppppppppppppppppqo&MMW#maWb%$@$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$@$@oMawppppppppppppppppppppppppppppppppwkWWah&M*#o8$@$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$@$B*#odqqpppppppppppppppppppppppppppqqa#MMoo##&8@$@$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$@$@WW#okqpwqqqqqqqqqqqqqqqqqqqqqpqph*#MW&8&&%@$$@$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$@$$B8MM*p#aaaaaaaaaaaahhhahhhokp**#8%$$$$$$$$@@$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$@@$$@####o**##M*M###MW&WM&&W*M**o%@$@@$$@@@$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$@@$%W*MB@@@@@@@@@@@@@@@@@@M*##B$@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$@$$@$$$$$$$$$$$$$$$$$$$$$@@$$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@@$@@@@@@@@@@@@@@$@@$$@@$$@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

this.

Solution

We can apply some heuristics to clear out the background. One heuristic is that Pusheen is typically at the center of the image, which means that we can probably use the corners to act as a threshold to remove the background.


More Problems + Solutions

In the real world, you’d probably want to 0 out everything non-Pusheen, but since this image will be piped to the terminal, it helps to contrast with the non-empty characters around the image.

1) We need to add a background (and after we went through all that trouble to get rid of it….)

We are using img.max() to scale our image, so one hacky solution is to use the max value and scale it by some percentage.

2) Our choice to scale the image size before changing the background, our chosen parameters are all wonky. We can just swap the order of our operations by changing the background, then scaling the image.

3) However, we now have to contend with scenarios where the background is black or white. We simplify the problem by checking if the image is below some “sensible” threshold, and if it is, we set it to some percentage of the max.

Special Thanks

* ASCII converter 1 for providing me with a starting point for code, and ASCII converter 2 for providing a more detailed ‘gradient’ of colors for Pusheen to exist in. Both were extremely useful in providing a starting point for the ASCII art converter

* Frolian - flothesof for making me realize that OpenCV is for lazy people (lazy people who happen to be able to figure out how to install it ¯\(ツ)/¯)