-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSRS怎么转回RGB,已执行完test_swinfusion.py #32
Comments
import os
from PIL import Image
import PIL
from natsort import natsorted
from tqdm import tqdm
def img2RGB(f_name, vi_name):
vi_img = Image.open(vi_name)
vi_img = vi_img.convert('YCbCr')
f_img = Image.open(f_name).convert('L')
vi_Y, vi_Cb, vi_Cr = vi_img.split()
f_img = Image.open(f_name).convert('L')
f_img = Image.merge('YCbCr', (f_img, vi_Cb, vi_Cr))
f_RGB = f_img.convert('RGB')
f_RGB.save(f_name)
if __name__ == '__main__':
fusion_folder = '' ## 融合图像所在的文件夹
vi_filoder = '' ## 可见光图像所在的文件夹 两个文件夹里的图片命名需要保持一致
file_list = os.listdir(fusion_folder)
file_bar = tqdm(file_list)
for file in natsorted(file_bar):
f_name = os.path.join(fusion_folder, file)
vi_name = os.path.join(vi_filoder, file)
img2RGB(f_name, vi_name)
file_bar.set_description('Y2RGB %s' % file)
你可以使用上述代码将Y通道的图像转换成彩色图像哈
joyyy111 ***@***.***> 于2024年7月17日周三 15:07写道:
…
作者你好,我现在用到的数据集是MSRS,我先把VI可见光的RGB图像通过blog提取出了Y通道,并把图片放入到了项目的VI_Y中,之后执行test_swinfusion.py,得到的是灰色单通道图像,至于如何转回RGB我不是很清楚?
是拿红外IR与test_swinfusion的结果转回RGB吗?用的是您提到的博客的 “ 只有一幅源图像为彩色图像”
这个方法吗?我试验了这个方法,结果返回报错的是:ValueError: the input array must have size 3 along
channel_axis, got (480,
640),我已将test_swinfusion跑通,但最后的灰色图像明显不是想要的结果,到底最后怎么转会RGB十分想请教一下
—
Reply to this email directly, view it on GitHub
<#32>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOFH5IJ3FSCKPBXZ3DOBVHDZMYJZ3AVCNFSM6AAAAABK77W7LWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQYTEOBTGI4DSOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
你加我QQ 我远程看看吧 2458707789 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
作者你好,我现在用到的数据集是MSRS,我先把VI可见光的RGB图像通过blog提取出了Y通道,并把图片放入到了项目的VI_Y中,之后执行test_swinfusion.py,得到的是灰色单通道图像,至于如何转回RGB我不是很清楚?
是拿红外IR与test_swinfusion的结果转回RGB吗?用的是您提到的博客的 “ 只有一幅源图像为彩色图像” 这个方法吗?我试验了这个方法,结果返回报错的是:ValueError: the input array must have size 3 along
channel_axis
, got (480, 640),我已将test_swinfusion跑通,但最后的灰色图像明显不是想要的结果,到底最后怎么转会RGB十分想请教一下The text was updated successfully, but these errors were encountered: