JonasSchatz / DepixHMM

Recovers pixelized text from images
MIT License
160 stars 12 forks source link

How to crop the image? #5

Open i-am-leo opened 1 year ago

i-am-leo commented 1 year ago

When I run your code, I get an error saying that the number of k-means clusters is not valid. I am still not sure how to crop the image. If it is an image with a block size of 6, how should I crop the image?

JonasSchatz commented 1 year ago

Ahh yes, the cropping issue :D

First of all, you should have identified the font/font-size that is most likely used. I have not found (meaning I have not looked) a way to automatically determine the symbols that are the "highest" / "lowest" or the letters with biggest ascent and descent, so you have to try out a bit. You have to crop your images in a way that the height and width are obviously multiples of 6, and the height should be so that the highest/lowest letters fit into your cropped image, even if this let some completely white rows at the top and/or bottom.

If you have an example, you can post it here. If it is this one: https://github.com/i-am-leo/pic/blob/main/response.png it might become difficult, because there is more than just simple pixelation going on.

i-am-leo commented 1 year ago

I tried this image

image

.This is directly cropped on the sample image, but it prompts me "X has 96 features, but KMeans is expecting 72 features as input". Do you know the reason?

i-am-leo commented 1 year ago
image
Xunda821 commented 2 months ago

IMG-20240918-WA0242