I am trying to take contour of an image and rotate that contour alone. so I want to store the contour as a separate image. please help me with the code and thanks in advance:)
Related
First image is the Original image. Second image is the Processed image. The image consists of a test tube containing some amount of precipitate at the bottom. I am trying to crop out only the Precipitate area of the image.
For achieving this, I have tried processing the original image so that the Upper edge of precipitate is detected. I am able to detect the upper edge of precipitate as you can see in the Processed image.
My question is, how do I crop the image from that upper edge to the bottom of test tube using OpenCV (Python) or some other library perhaps ? I am open to ideas and codes that can help. Thanks!
Original image
Processed image
The surface of the precipitate is bright.
This is what you can get by getting the saturation component, applying Gaussian filtering horizontally and binarizing.
Horizontal delimitation of the ROI should not be difficult.
I'm currently working on my thesis and I wanted to get the center of my regions in my image. Here is the region that I use.
From that regions, I wanted to get the center of it so I can give the center of a region a color from the original image.
I can't think of anything on how to get the center of the regions, but I already manage to make the regions into colors from the original image, like this
Can anyone help me how to find the center of the regions?
EDIT:
I already tried to make it into pieces, but it didn't go as planned
filter the matrix of your first image by value to get a binary image
find contours using cv2.findContours()
for each contour, find the center using cv2.moments()
I hope the images you put in your thesis are more... professional.
My original image was this:enter image description here
After I rotate them, I got this:
enter image description here
Therefore, I am currently having both black and white borders. I only want the middle part of the image, how can I crop them with Python?
I am new here, appreciate if anyone can help! Thanks in advance.
I have the following image in which I've detected the borders, representing 7 circles. In my opinion, it is fairly easy to identify the circles on it, but I am having trouble detecting all circles with the opencv Hough transform. Here it is what I've tried:
img = cv2.imread('sample.png',0)
edges = cv2.Canny(img,20,120)
circles = cv2.HoughCircles(edges,cv2.HOUGH_GRADIENT,1,100,
param2=40,minRadius=0,maxRadius=250)
I either get the central circle, the outer one or a lot of circles, depending on the parameters I input on the function. Do you guys have a set of parameters that would output all the circles?
Thanks in advance
Solved with this example from scikit-image adjusting canny thresholds to match the posted image and also the radii range.
Thanks to #barny
I am trying to crop only liver from this picture. I have tried everything but cannot find any useful information about it. I am using Python/Rstudio. Also after removing the unnecessary part, I am willing to get pixels/intensity of the new image. Any help would be appreciated. Please check one of the image This is somehow what I want to crop
UPDATE:
I am trying to crop the main image based on edges I got from the canny edge detector. Is there any way to crop the main image based on edges? Please check the images.
Liver Image
Canny Edge Detection
Well, if your images are static, same size, and taken from the same angle, then below simple script should suffice your needs:
import cv2
img = cv2.imread("cMyp9.png")
mask = np.where(img==255)
img2 = cv2.imread("your_next_image.png")
img2 [mask] = 255
now your img2 is a cropped version