Pusheen The Limit

19 Jan 2018

I love Pusheen, and I’m also a fan of playing around in my terminal. I was inspired to actually do this after talking to someone the other day; she mentioned how an officemate of hers commented on the Pusheen that popped up when she opened her shell. Firstly, I’m frankly disappointed in myself that I’ve never thought to do the same thing but I also saw it as a quick project that I could undertake that might bring joy to other people.

There isn’t really much stats in this problem - I used the standard deviation a little as a replacement for actually segmenting the image between ‘cat’ and ‘background’ so if that’s what you came here for you’re a little out of luck, but hopefully my next post will be about Bayesian ML as well as Pyro, Uber’s probabilistic programming language

Initial Problem

A quick Google search revealed that there are about 3 Pusheen ASCII art images online which is… disappointing given how many Pusheen images and GIFs there are. Thankfully, it’s a Friday night here, and I’m still exhausted from climbing recently; it looks like I’m making a Pusheen ASCII art converter + some shell scripts. Also, Pusheen sounds like pushin’ which makes for a load of fun, cute names which is honestly half of the reason I code: adorable github project names.


Process

1) Have a folder where some Pusheen images are stored

2) Load the images, and resize them before converting them 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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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbdk%o |
      })rW8ddbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbp&8z}}
       ) C8&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$$$$$@$$$$$$$$$$$$$$$$$$$$$$$$$$
$$$$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$$@@@##hqZOOwdko#ohdZLcXpbQzcpMqdppppppppppppo#MWoB$@$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$@$B&##W*okqwZZpba**oabqZ0zbMwpppppppppppppqpq#MB$@$$$$$$$$$$$$$$$$$$$$$$$
$$$$$$$$$$$$$$$$$$$$$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*#odqqpppppppppppppppppppppppppppq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

~Machine Learning (kind of, not really)~

Maybe it’s not a case with ALL Pusheen images, but I think the center generally includes Pusheen? Doesn’t really matter as we’ll first take a chunk of the center anyways.

1) Assume that the center typically includes the chunk that is Pusheen

2) Assume that the average of some region near the 4 corners does NOT include Pusheen

3) Either use 1) or 2) to zero out regions that are not Pusheen.

4) Move on with your Friday night

5) Consider using Mask R-CNN for the shiggles and to see whether it considers Pusheen to be a cat or a gift from above :^)


More Problems + Solutions

1) In an ideal world, yes, you’d want to 0 out everything that isn’t Pusheen, but this is terminal world and sometimes it helps to have a little bit of contrast with the non-empty characters around you. You now have a parameter, BACKGROUND, that needs to be determined for each image that comes in. Some statistics should help with this though…

2) Because you’re scaling the image size before changing the background, your carefully (not really) chosen parameters are all wonky.

3) Well, you thought that 2) would be an easy fix, but now you have to contend with cases where the background is black OR white, and you can’t use the same code for everything.

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 ¯\(ツ)/¯)

[ Fun  ]