我正在学习图像处理,其中我试图使用 python 中的 opencv 锐化图像的边缘,我已经尽可能地减少了噪声,但现在我想让图像的边缘更清晰,我已经尝试过了,cv2.Canny()但是但效果并不理想。
这是图像
应用 c2.Canny() 后
但我正在尝试使单词边框或边缘更清晰
这是我的代码
import cv2
import matplotlib.pyplot as plt
img_1 = cv2.imread('noise/1.png',cv2.IMREAD_GRAYSCALE)
edges = cv2.Canny(img_1,200,200)
plt.imshow(edges)
Run Code Online (Sandbox Code Playgroud) 我想在opencart代码示例中添加php电话号码验证,如下所示
if(!filter_var($customer_email, FILTER_VALIDATE_EMAIL)) {
$errors[$pos++] = 'Email is not valid.';
}
if($customer_mobile=='') {
$errors[$pos++] = 'Please enter your Mobile.';
} /*elseif (strlen($customer_mobile) < 11 || !is_numeric($this->request->post['cell_number'])){
$errors[$pos++] = 'Mobile number should be 7 digits.';
}*/
Run Code Online (Sandbox Code Playgroud) 我想用C语言编写一个程序来接受用户输入,我将无法理解循环的逻辑.
for ( c = 2 ; c <= n - 1 ; c++ )
Run Code Online (Sandbox Code Playgroud)
程序代码如下: -
#include<stdio.h>
#include<conio.h>
void main()
{
int n, c;
printf("Enter a number to check if it is prime\n");
scanf("%d", &n);
for ( c = 2 ; c <= n - 1 ; c++ )
{
if ( n % c == 0 )
{
printf("%d is not prime.\n", n);
break;
}
}
if ( c == n )
printf("%d is prime.\n", n);
getch();
} …Run Code Online (Sandbox Code Playgroud) 在计算 langitude 和 longitude 之间的距离时,数据帧列中重复相同的值。我创建了一个动态列来查找每个源到目的地之间的距离,但每列的所有值都是重复的。
for a,b,x in zip(df.Longitude,df.Latitude,df.index):
for c,d in zip(df.Longitude,df.Latitude):
df['distance_'+str(x)]=haversine(a,b,c,d)
Run Code Online (Sandbox Code Playgroud)
假设这是数据框
index name lat long
0 a 74.299104 31.481188
1 b 74.351619 39.481188
2 c 73.351619 39.481188
Run Code Online (Sandbox Code Playgroud)
现在我想要这样的预期结果
index name lat long distanceA distanceB distanceC
0 a 74.299104 31.481188 0 4.5 2.4
1 b 74.351619 39.481188 5.7 0 5.8
2 c 73.351619 39.481188 3.8 1.3 0
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过测试一些用例来学习 opencv 并实施一个研究项目。我正在尝试使用 python opencv 裁剪图像内部的边界框。我已成功创建边界框,但裁剪失败
这是图片
import cv2
import matplotlib.pyplot as plt
img = cv2.imread("Segmentacion/Img_183.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dst = cv2.Canny(gray, 0, 150)
blured = cv2.blur(dst, (5,5), 0)
MIN_CONTOUR_AREA=200
img_thresh = cv2.adaptiveThreshold(blured, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 11, 2)
Contours,imgContours = cv2.findContours(img_thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
for contour in Contours:
if cv2.contourArea(contour) > MIN_CONTOUR_AREA:
[X, Y, W, H] = cv2.boundingRect(contour)
box=cv2.rectangle(img, (X, Y), (X + W, Y + H), (0,0,255), 2)
cropped_image = img[X:W, Y:H]
print([X,Y,W,H])
cv2.imwrite('contour.png', cropped_image )
Run Code Online (Sandbox Code Playgroud)