I have a microscopic image with grid of straight lines (not vertical or horizontal).
I know that ImageMagick have -hough-lines operator that can detect straight lines. How to use it to remove such lines?
I have a microscopic image with grid of straight lines (not vertical or horizontal).
I know that ImageMagick have -hough-lines operator that can detect straight lines. How to use it to remove such lines?
Copyright © 2021 Jogjafile Inc.

Here is one way to process your image in Imagemagick.
(Note that -hough-lines is only accurate to 1 degree. So it can find the lines, but they will not be aligned well enough to use them for removal.)
There are two major steps. First find the angle of rotation. Second rotate the image and then use morphology to remove the horizontal and then the vertical lines.
Input:
First step does a division normalization to even out the background white, then does an automatic threshold, then does a -deskew to get the rotation angle. I have included +write xxx.png to save the images step-by-step. You can remove these +write xxx.png, but not the -write mpr:xxx.
Division Normalized:
Division Normalized and Thresholded:
Division Normalized, Thresholded and Deskewed:
Second Step starts with the previous division normalized image and rotates it. Then it takes the previous deskewed image and apply a horizontal morphology close, negates it to make the lines white on black and adds that to the rotated image. Then it applies a vertical morphology close to the deskewed image, negates it to make the lines white on black and adds that to the previous result from the horizontal processing. This forms the final result.
Division Normalized and Rotated Input:
Division Normalized, Rotated and Thresholded Input:
Morphology Close Horizontal:
Morphology Close Horizontal Added To Rotated Image:
Morphology Close Vertical:
Morphology Close Vertical Added To Previous Result - Final Image: