Image processing is a method to perform some operations on an image, in order to get an enhanced image or to extract some useful information from it.

A pipeline is a some set of operations connected in a series, where the output of one is the input of the next one. In image processing, a task can be achieved through many different pipelines with different qualities.

My advise for anyone who is trying to start a project with a new framework is not to try to learn everything about that framework before the start of the project. You can get to know it while you are doing it. It’s better to have a general idea about what we can do with this technology and blueprint of the project. Lets take this project as a example.

In this project, our final goal is to extract large vessels and small vessels separately. The blood vessels were highlighted in the image because they were darker than others. So at first i thought if I am able to filter all the vessels by color(it does not work), then I can remove small vessels by smoothing or blurring and extract the large vessels. After that all I needed to do was subtract large vessels from all vessels and extract small vessels. This was my initial path to the goal.

Then I found a way to detect object using HSV color space. Here is the code.

import cv2
	import numpy as np

	def nothing(x):

	cv2.createTrackbar("LH", "Tracking", 0, 255, nothing)
	cv2.createTrackbar("LS", "Tracking", 0, 255, nothing)
	cv2.createTrackbar("LV", "Tracking", 0, 255, nothing)
	cv2.createTrackbar("UH", "Tracking", 255, 255, nothing)
	cv2.createTrackbar("US", "Tracking", 255, 255, nothing)
	cv2.createTrackbar("UV", "Tracking", 255, 255, nothing)

	while True:
	    frame = cv2.imread('Fundus Image.jpg')

	    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

	    l_h = cv2.getTrackbarPos("LH", "Tracking")
	    l_s = cv2.getTrackbarPos("LS", "Tracking")
	    l_v = cv2.getTrackbarPos("LV", "Tracking")

	    u_h = cv2.getTrackbarPos("UH", "Tracking")
	    u_s = cv2.getTrackbarPos("US", "Tracking")
	    u_v = cv2.getTrackbarPos("UV", "Tracking")

	    l_b = np.array([l_h, l_s, l_v])
	    u_b = np.array([u_h, u_s, u_v])

	    mask = cv2.inRange(hsv, l_b, u_b)

	    res = cv2.bitwise_and(frame, frame, mask=mask)

	    cv2.imshow("frame", frame)
	    cv2.imshow("mask", mask)
	    cv2.imshow("res", res)

	    key = cv2.waitKey(1)
	    if key == 27:


mask & res output with trackbar

Here you can change parameters and see how the output changes. Click escape button to close it. The above figure was the best one I got by this and I was not satisfied with the outputs. Then I tried it with increasing brightness and contrast at the beginning. But it did not give me the thing I want. So I decided to move on to another method.

#python #blood-vessel #image-processing #segmentation #programming

What I learned from my first Image Processing Project
1.40 GEEK