ssreckovic / Music-Reader

This program is intended to read an image file of sheet music, in the future it should be able to play it back.
0 stars 0 forks source link

remove lines #1

Open abdallahabusedo opened 3 years ago

abdallahabusedo commented 3 years ago

I just read your code and try it on this image 02 I notice that there a line did not remove so I try to fix the code to make it like this

def eraseLine(thickness, startLine, image, picWidth): #doesn't erase line, but make them white

    topLine = startLine
    botLine = startLine + thickness -1
    for col in range(picWidth):
        if image.item(topLine,col) == 0 or image.item(botLine,col) == 0:
            if image.item(topLine-1, col) == 255 and image.item(botLine+1,col) == 255:
                for j in range(thickness):
                    image.itemset((topLine+j,col),255)
            elif image.item(topLine - 1, col) == 255 and image.item(botLine+1,col) == 0:
                thick = thickness+1
                if thick < 1:
                    thick = 1
                for j in range(int(thick)):
                    image.itemset((topLine + j, col),255)

            elif image.item(topLine - 1, col) == 0 and image.item(botLine+1,col) == 255:
                thick = thickness+1
                if thick < 1:
                    thick = 1
                for j in range(int(thick)):
                    image.itemset((botLine - j, col),255)
return image 

and I fix it

abdallahabusedo commented 3 years ago

this is the photo after fixing image this is the result before fixing the code image