When I use the canvas to enlarge images, they are blurred. Would it be possible to enlarge the image without blurring?
Original image (attached):
Enlarged image which I want (magnifying tool - paint.net image editor)
canva drawbitmap result (blurred)
code:
B4X:
Sub Button1_Click
Dim can As Canvas, img As Image
can.Initialize("")
img.Initialize(File.Dirapp, "original.png")
Dim mag As Int = 20
can.SetSize(img.Width*mag, img.Height*mag)
can.DrawImage(img, 0,0,img.Width*mag, img.Width*mag)
MainForm.RootPane.AddNode(can,200,100,can.Width,can.Height)
End Sub
you either have to start with a larger image or you have to use a vector image or you have to draw a "6" with a large font. you can't take such a small raster image and enlarge it without losing all sharpness.
It is not easy to achieve this for bitmap since the data is stored as pixels. There are methods like superpixel: http://waifu2x.udp.jp/ , but not suitable for this situation.
you either have to start with a larger image or you have to use a vector image or you have to draw a "6" with a large font. you can't take such a small raster image and enlarge it without losing all sharpness.
I'm actually cutting small portions of the screen (playing cards), then using tesseract to decode the corresponding character (A, K, Q, J, 10, 9 ... etc).
I tried with opencv and tensorflow, but it got really complicated.
I doubt that magnifying the character bitmaps will help Tesseract or any other OCR.
In fact, if the characters are coming from text rendered to pixels, and not from a scanner or camera, then you probably have advantages such as:
- consistent size
- consistent shape
- perfectly level
- known consistent color
- limited character set
- known position
- known plain background
and you might be better off just whipping up your own brute-force scan-area-using-mask algorithm.
caveat: I'm assuming you're writing to scrape data off your own screen, and we're not trying to do it off of multiple screen sizes, resolutions and color schemes.
I'd be interested to see a few screenshots of what you're trying to capture (I'm assuming online card games, and I happen to be a bit of a gambler myself, so don't be shy ? you're amongst friends here ?).
I think the point has been misunderstood. I think he wants to enlarge without anti-aliasing the final image. Whether or not the absence of anti-aliasing will help his use case is a different matter!
I doubt that magnifying the character bitmaps will help Tesseract or any other OCR.
In fact, if the characters are coming from text rendered to pixels, and not from a scanner or camera, then you probably have advantages such as:
- consistent size
- consistent shape
- perfectly level
- known consistent color
- limited character set
- known position
- known plain background
and you might be better off just whipping up your own brute-force scan-area-using-mask algorithm.
caveat: I'm assuming you're writing to scrape data off your own screen, and we're not trying to do it off of multiple screen sizes, resolutions and color schemes.
I'd be interested to see a few screenshots of what you're trying to capture (I'm assuming online card games, and I happen to be a bit of a gambler myself, so don't be shy ? you're amongst friends here ?).