簡體   English   中英

MATLAB轉Julia RGB圖像轉換

[英]MATLAB to Julia RGB image conversion

我正在處理 RGB、2D 圖像。

在 MATLAB 我可以做類似的事情

imread(img, "file.png")
# access img(2, 4, 1) for the red color channel
# access img(2, 4, 2) for the green color channel

在 Julia 我想做類似的事情......

load("file.png", img)
# access img[2, 4, 1] will not work

我知道這是因為圖像在 Julia 中的編碼方式。但是有沒有辦法將 Julia 中的這些矩陣轉換為匹配 MATLAB 中使用的格式?

作為 Julia 新手,我提前道歉,找不到任何文檔

為此,您可以使用FileIOColors包:

using FileIO, Colors
# load png
img = FileIO.load("file.png")
# access each channel with any of the following access patterns
green.(img)
red(img[begin, end-3])
blue.(img[1:4, 5:7])

如果您的 PNG 具有透明度,您可以通過 function alpha訪問 alpha,類似於上面的紅色、綠色和藍色函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM