madan ram
madan ram

Reputation: 1270

What filter is used to remove corner effect on result

Below is output enter image description here

Here are those marked in red circle. There are lots of such line the image, I have marked only 3 circle. How to remove these lines? Is there any filter to remove this line? I think, this is due to presence of corner.

Upvotes: 2

Views: 216

Answers (1)

dhruvvyas90
dhruvvyas90

Reputation: 1205

You can use Median filter to remove that thing.

Try this code and see the difference while changing the value of the trackbar (mask size).

import cv2
import numpy as np

def nothing(x):
    pass

#image window
cv2.namedWindow('image')
cv2.namedWindow('image2')

# create trackbars for color change
cv2.createTrackbar('mask','image',1,10,nothing)
cv2.createTrackbar('mask2','image2',1,10,nothing)

#loading images
img = cv2.imread('VfgSN.png')     # load your image with path
gray_im = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

while True:
    # get current positions of trackbars
    m = cv2.getTrackbarPos('mask','image')
    m2 = cv2.getTrackbarPos('mask2','image2')
    median = cv2.medianBlur(gray_im,(2*m+1))
    median2 = cv2.medianBlur(img,(2*m2+1))
    cv2.imshow('image',median)
    cv2.imshow('image2',median2)
    #press ESC to stop
    k = cv2.waitKey(1) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()

Resultant image with mask : 5

enter image description here

In grayscale (with the same mask)

enter image description here

But then it also affects the other parts of the image. If you don't want that to happen to the other part. You can apply this filter in your Region of Interest only.

Hope it helps.

Upvotes: 4

Related Questions