需要将下面给出的图片的白色像素更改为黑色,将黑色像素更改为白色
import cv2
img=cv2.imread("cvlogo.png")
Run Code Online (Sandbox Code Playgroud)
带有白色背景的基本 opencv 徽标并将图片调整为固定的已知大小
img=cv2.resize(img, (300,300))#(width,height)
row,col=0,0
i=0
Run Code Online (Sandbox Code Playgroud)
现在使用 for 循环检查每个像素的行和列位置
如果像素为白色,则将其更改为黑色;如果像素为黑色,则将其更改为白色。
for row in range(0,300,1):
print(row)
for col in range(0,300,1):
print(col)
if img[row,col] is [255,255,255] : #I have used == instead of 'is'..but there is no change
img[row,col]=[0,0,0]
elif img[row,col] is [0,0,0]:
img[row,col]=[255,255,255]
Run Code Online (Sandbox Code Playgroud)
执行中没有错误,但不会将像素值分别更改为黑色或白色。更多 if 语句也没有执行..太混乱了..
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud) 如何在数据表中使用 PrimeNG 的默认过滤器过滤后获取行数。
[totalRecords]="totalRecords"
始终显示最初获取的记录数。
即使经过过滤,totalRecords
值仍然保持不变并且过滤后不会改变。
例如:最初totalRecords
是50,过滤后,数据表中显示的记录数是15。但是我无法得到值15,而是得到50。
有什么办法吗?