mathematical-morphology

gpu::morphologyEx is slower than morphologyEx in CPU?

我怕爱的太早我们不能终老 提交于 2019-12-11 10:22:56
问题 I am writing a c++ code for comparing the performance of morphologyEx method of opencv using the CPU and GPU versions. Here is my code: #include <opencv2/opencv.hpp> #include <opencv2/gpu/gpu.hpp> #include <sys/time.h> #include <ctime> using namespace cv; using namespace std; double start_timer() { double start_time = (double) getTickCount(); return start_time; } double end_timer(double start_time,int num_tests) { double time = (1000 * ((double) getTickCount() - start_time)/ getTickFrequency(

Implementation of image dilation and erosion

帅比萌擦擦* 提交于 2019-12-11 06:43:11
问题 I am trying to figure out an efficient way of implementing image dilation and erosion for binary images. As far as I understand it, the naive way would be: loop through the image if pixel is 1 loop through the neighborhood based on the structuring element's height and width (dilate) substitute each pixel of the image with the value in the corresponding location of the SE (erode) check if all neighborhood is equal to the SE, if so keep all the pixels, else delete the centre so this means that

adaptive elliptical structuring element in MATLAB

萝らか妹 提交于 2019-12-11 06:07:34
问题 I'm trying to create an adaptive elliptical structuring element for an image to dilate or erode it. I write this code but unfortunately all of the structuring elements are ones(2*M+1) . I = input('Enter the input image: '); M = input('Enter the maximum allowed semi-major axes length: '); % determining ellipse parameteres from eigen value decomposition of LST row = size(I,1); col = size(I,2); SE = cell(row,col); padI = padarray(I,[M M],'replicate','both'); padrow = size(padI,1); padcol = size

OpenCV - Retaining only marked blobs in python

China☆狼群 提交于 2019-12-11 01:52:01
问题 I have a morphological problem i am attempting to solve using OpenCV. I have two images. Mask Seed In the mask image am trying to retain only the blobs marked by a seed image and to remove the rest. Underneath I am posting the mask and seed image Mask Image : Seed Image : To further illustrate a the problem I have zoomed into the image and created a subplot. In this example the plot on your right is the seed image, the plot your left is the mask image. At the end of the operation I would like

implementing erosion, dilation in C, C++

被刻印的时光 ゝ 提交于 2019-12-04 09:44:39
问题 I have theoretical understanding of how dilation in binary image is done. AFAIK, If my SE (structuring element) is this 0 1 1 1. where . represents the centre, and my image(binary is this) 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 so the result of dilation is 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 I got above result by shifting Image in 0, +1 (up) and and -1(left) direction, according to SE, and taking the union of all these three shifts. Now, I need to figure out how to

Need only one edge in Canny edge algorithm

匆匆过客 提交于 2019-12-03 13:03:49
问题 When i use the canny edge algorithm, it produces the 2 edges opposite the thick colored line as expected, but i want only one edge to be displayed so as to make my line and curve detection algorithm much less complicated, any ideas on how i can make that happen ? Here is the code : bool CannyEdgeDetection(DataStructure& col) { Mat src, src_gray; Mat dst, detected_edges, fin; int WhiteCount = 0, BCount = 0; char szFil1[32] = "ocv.bmp"; char szFil2[32] = "dst.bmp"; src = imread(szFil1); dst =

OpenCV grooving detection

余生长醉 提交于 2019-12-03 08:37:48
问题 I have pictures of a surface with many grooves. In most cases the edges of the grooving form parallel lines so Canny and Hough transformation work very good to detect the lines and to do some characterization. However, at several places the grooving is demaged and the edges aren't parallel anymore. I am looking for an easy way to check if a certain edge is a straight line or if there are any gaps or deviations from a straight line. I am thinking of something like the R square parameter in

How can i find cycles in a skeleton image with python libraries?

≡放荡痞女 提交于 2019-12-03 07:28:22
I have many skeletonized images like this: How can i detect a cycle, a loop in the skeleton? Are there "special" functions that do this or should I implement it as a graph? In case there is only the graph option, can the python graph library NetworkX can help me? You can exploit the topology of the skeleton. A cycle will have no holes, so we can use scipy.ndimage to find any holes and compare. This isn't the fastest method, but it's extremely easy to code. import scipy.misc, scipy.ndimage # Read the image img = scipy.misc.imread("Skel.png") # Retain only the skeleton img[img!=255] = 0 img =

implementing erosion, dilation in C, C++

无人久伴 提交于 2019-12-03 03:09:47
I have theoretical understanding of how dilation in binary image is done. AFAIK, If my SE (structuring element) is this 0 1 1 1. where . represents the centre, and my image(binary is this) 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 so the result of dilation is 0 1 1 0 0 1 1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 I got above result by shifting Image in 0, +1 (up) and and -1(left) direction, according to SE, and taking the union of all these three shifts. Now, I need to figure out how to implement this in C, C++. I am not sure how to begin and how to take the union of sets. I thought of

Scipy ndimage morphology operators saturate my computer memory RAM (8GB)

痞子三分冷 提交于 2019-12-01 19:59:47
I need to compute morphological opening for 3D array of shape (400,401,401), size 64320400 bytes using a 3D structure element with a radius of 17 or greater. The size of structure element ndarray is 42875 bytes. Using scipy.ndimage.morphology.binary_opening , the whole process consumes 8GB RAM. I have read scipy/ndimage/morphology.py on GitHub, and as far as I can tell, the morphology erosion operator is implemented in pure C. It is to difficult for me to understand the ni_morphology.c source, so I haven't found any part of this code which leads to such enormous memory utilization. Adding more