久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Python openCV 中顯示 16 位 4096 強度圖像?

How to display 16-bit 4096 intensity image in Python openCV?(如何在 Python openCV 中顯示 16 位 4096 強度圖像?)
本文介紹了如何在 Python openCV 中顯示 16 位 4096 強度圖像?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有以灰度 16 位 tiff 格式編碼的圖像.他們使用 16 位顏色深度的變體,其中最大強度為 4,096.

I have images encoded in grayscale 16-bit tiff format. They use a variant of 16-bit color depth where the max intensity is 4,096.

我相信 openCV 中的默認最大強度是 65,536,所以我的圖像使用以下代碼顯示為黑色.

I believe the default max intensity in openCV is 65,536, so my image shows up as black using the following code.

import cv2

image = cv2.imread("test.tif", -1)

cv2.imshow('tiff', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(image)

我可以在matplotlib中使用vminvmax來配置顏色映射:

I can use vmin and vmax in matplotlib to configure the color mapping:

import cv2
import matplotlib.pyplot as plt 

image = cv2.imread("test.tif", -1)
plt.imshow(image, cmap="gray", vmin=0, vmax=4096)
plt.show()

顯示圖片的內容:

我要堅持使用openCV的原因是matplotlib不支持顯示16位RGB圖像.

The reason why I want to stick with openCV is matplotlib doesn't support displaying 16-bit RGB images.

cv2 的文檔.imshow 并不是很有幫助.有沒有辦法在 Python openCV 中顯示 16 位 4096 強度圖像?

The documentation of cv2.imshow is not really helpful. Are there ways to display 16-bit 4096 intensity images in Python openCV?

測試圖像 test.tif 可以找到 這里.

The testing image test.tif can be found here.

推薦答案

你會想要使用 cv2.normalize() 在顯示之前縮放圖像.

You'll want to use cv2.normalize() to scale the image before displaying.

您可以設置圖像的最小值/最大值,它會適當地縮放圖像(通過將圖像的最小值移動到 alpha 并將圖像的最大值移動到 beta).假設你的 img 已經是 uint16:

You can set the min/max of the image and it will scale the image appropriately (by moving the min of the image to alpha and max of the image to beta). Supposing your img is already a uint16:

img_scaled = cv2.normalize(img, dst=None, alpha=0, beta=65535, norm_type=cv2.NORM_MINMAX)

然后就可以正常觀看了.

And then you can view as normal.

默認情況下,cv2.normalize() 將生成與輸入圖像相同類型的圖像,因此如果您想要一個無符號的 16 位結果,您的輸入應該是 uint16.

By default, cv2.normalize() will result in an image the same type as your input image, so if you want an unsigned 16-bit result, your input should be uint16.

再次,請注意,這會線性拉伸您的圖像范圍 --- 如果您的圖像從未真正達到 0 并且說最小值是 100,那么在您標準化之后,該最小值將是您設置的任何值 alpha 到.如果您不希望這樣,正如其中一條評論所建議的那樣,您可以簡單地將您的圖像乘以 16,因為它目前只上升到 4095.使用 * 16,它將上升到 65535.

Again, note that this linearly stretches your image range---if your image never actually hit 0 and say the lowest value was 100, after you normalize, that lowest value will be whatever you set alpha to. If you don't want that, as one of the comments suggests, you can simply multiply your image by 16, since it's currently only going up to 4095. With * 16, it will go up to 65535.

這篇關于如何在 Python openCV 中顯示 16 位 4096 強度圖像?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 天堂色网 | 日本成人综合 | 欧美激情国产日韩精品一区18 | 国产日韩精品一区二区 | 亚洲国产一区视频 | 欧美精品在线免费观看 | 欧美视频成人 | 国产一区二区三区四区 | 精品一区二区三区入口 | 欧美一区二区三区在线看 | 在线免费观看黄a | 久操伊人 | 欧美一区二区三区在线观看 | 国产欧美日韩一区二区三区在线 | 99视频免费| 一级毛片免费 | 国产男女猛烈无遮掩视频免费网站 | 91视频一区二区三区 | 黑人性hd| 日韩一区二区三区在线 | 久久99精品久久久久久 | 97国产精品视频人人做人人爱 | 久久久久久久91 | 国产精品久久久久久久久久妇女 | 国精品一区| 日韩一区在线播放 | 久久久www成人免费精品 | 在线一区视频 | 在线视频日韩 | 日韩欧美在线视频 | 一级黄色片在线免费观看 | 天天操天天玩 | 亚洲综合视频一区 | 国产一级片免费看 | www亚洲成人 | 在线中文字幕av | 波多野结衣一区二区三区 | 免费在线观看成人av | 国产www成人 | 黄网站涩免费蜜桃网站 | 综合精品在线 |