图像融合项目:闪光与非闪光图片的信息融合技术

版权申诉
0 下载量 93 浏览量 更新于2024-11-08 收藏 4KB ZIP 举报
资源摘要信息: "back_seg_code.zip_back_back images_fusion" 该压缩包文件的标题为 "back_seg_code.zip_back_back images_fusion",从标题中可以推测该文件包含了一系列与图像处理相关的代码文件,这些文件可能用于实现图像的融合技术,特别是针对闪光灯和非闪光灯条件下的图像信息融合。描述中提到的是一个名为 "Information Fusion of Flash and Non-Flash Images" 的项目,这表明该项目专注于研究在不同光照条件下对图像进行信息融合的算法。标签 "back back_images fusion" 进一步强调了该压缩包是关于图像融合技术的。 从提供的文件名称列表中,我们可以推断出这些文件可能执行以下功能: 1. fuzzy_segment2.m 和 fuzzy_segment.m:这两个文件名包含 "fuzzy" 和 "segment" 关键字,很可能与模糊逻辑分割算法有关。模糊逻辑分割是处理图像时用于确定像素属于特定区域程度的一种技术,这在图像融合中非常有用,因为需要根据像素的模糊属性来合并不同的图像信息。 2. classify_img2.m 和 classify_img.m:这些文件很可能与图像分类有关,意味着它们可以用于将图像分配到不同的类别,这可能是后续信息融合步骤的一个组成部分,其中不同的图像类别可能会有不同的融合策略。 3. getCubes.m 和 mask_image.m:这些文件名暗示它们可能与图像的三维处理和掩码操作有关。"getCubes" 可能指的是将图像划分为小块(或立方体),而 "mask_image" 可能涉及创建一个掩码来选择性地保留或排除图像中的某些区域,这是图像处理中的常见技术,有助于在融合过程中集中注意力于感兴趣的区域。 4. fuzzy_classify2.m 和 fuzzy_classify.m:这些文件看起来是分类算法的另一版本,使用了模糊逻辑。模糊分类可以处理图像中的不确定性,因为现实世界中的图像往往包含着不清晰或者边缘不明的情况。 5. scaleData.m 和 randomize_tdata.m:这两个文件名表明它们可能负责数据的缩放(scale)和随机化(randomization)。在图像处理中,对数据进行缩放可能是为了调整图像大小以便于处理,而数据随机化则可能用于创建测试集或校验算法的有效性。 综合以上信息,可以得出这个压缩包是关于图像处理和图像融合技术的,特别涉及到闪光灯与非闪光灯图像的信息整合。这些代码文件可能构成一个综合性的图像处理框架,用于处理、分类、分割、融合以及预处理图像数据。在实际应用中,这样一套系统可以用于改善图像质量,比如在夜间摄影或医学图像分析中,通过融合不同条件下的图像来提升最终图像的细节和对比度。这套技术也广泛应用在安全监控、视觉效果增强以及计算机视觉的其他领域。

给出相同功能的代码import os import numpy as np import nibabel as nib import imageio from PIL import Image def read_niifile(niifilepath): # 读取niifile文件 img = nib.load(niifilepath) # 提取niifile文件 img_fdata = img.get_fdata(dtype='float32') return img_fdata def save_fig(niifilepath, savepath, num, name): # 保存为图片 name = name.split('-')[1] filepath_seg = niifilepath + "segmentation\" + "segmentation-" + name filepath_vol = niifilepath + "volume\" + "volume-" + name savepath_seg = savepath + "segmentation\" savepath_vol = savepath + "volume\" if not os.path.exists(savepath_seg): os.makedirs(savepath_seg) if not os.path.exists(savepath_vol): os.makedirs(savepath_vol) fdata_vol = read_niifile(filepath_vol) fdata_seg = read_niifile(filepath_seg) (x, y, z) = fdata_seg.shape total = x * y for k in range(z): silce_seg = fdata_seg[:, :, k] if silce_seg.max() == 0: continue else: silce_seg = (silce_seg - silce_seg.min()) / (silce_seg.max() - silce_seg.min()) * 255 silce_seg = np.uint8(Image.fromarray(silce_seg).convert('L')) silce_seg = cv2.threshold(silce_seg, 1, 255, cv2.THRESH_BINARY)[1] if (np.sum(silce_seg == 255) / total) > 0.015: silce_vol = fdata_vol[:, :, k] silce_vol = (silce_vol - silce_vol.min()) / (silce_vol.max() - silce_vol.min()) * 255 silce_vol = np.uint8(Image.fromarray(silce_vol).convert('L')) imageio.imwrite(os.path.join(savepath_seg, '{}.png'.format(num)), silce_seg) imageio.imwrite(os.path.join(savepath_vol, '{}.png'.format(num)), silce_vol) num += 1 return num if name == 'main': path = r'C:\Users\Administrator\Desktop\LiTS2017' savepath = r'C:\Users\Administrator\Desktop\2D-LiTS2017' filenames = os.listdir(path + "segmentation") num = 0 for filename in filenames: num = save_fig(path, savepath, num, filename)

2023-05-25 上传

替换掉此代码里的import cv2模块,import os import numpy as np import nibabel as nib import imageio import cv2 def read_niifile(niifilepath): # 读取niifile文件 img = nib.load(niifilepath) # 提取niifile文件 img_fdata = img.get_fdata(dtype='float32') return img_fdata def save_fig(niifilepath, savepath, num, name): # 保存为图片 name = name.split('-')[1] filepath_seg = niifilepath + "segmentation\" + "segmentation-" + name filepath_vol = niifilepath + "volume\" + "volume-" +name savepath_seg = savepath + "segmentation\" savepath_vol = savepath + "volume\" if not os.path.exists(savepath_seg): os.makedirs(savepath_seg) if not os.path.exists(savepath_vol): os.makedirs(savepath_vol) fdata_vol = read_niifile(filepath_vol) fdata_seg = read_niifile(filepath_seg) (x, y, z) = fdata_seg.shape total = x * y for k in range(z): silce_seg = fdata_seg[:, :, k] # 三个位置表示三个不同角度的切片 if silce_seg.max() == 0: continue else: silce_seg = (silce_seg-silce_seg.min())/(silce_seg.max() - silce_seg.min())*255 silce_seg = cv2.threshold(silce_seg, 1, 255, cv2.THRESH_BINARY)[1] if (np.sum(silce_seg == 255) / total) > 0.015: silce_vol = fdata_vol[:, :, k] silce_vol = (silce_vol - silce_vol.min()) / (silce_vol.max() - silce_vol.min()) * 255 imageio.imwrite(os.path.join(savepath_seg, '{}.png'.format(num)), silce_seg) imageio.imwrite(os.path.join(savepath_vol, '{}.png'.format(num)), silce_vol) num += 1 # 将切片信息保存为png格式 return num if name == 'main': path= 'E:\dataset\LiTS17\' savepath = 'E:\dataset\LiTS17\2d\' filenames = os.listdir(path + "segmentation") num = 0 for filename in filenames: num = save_fig(path, savepath, num, filename)

2023-05-25 上传

import os import numpy as np import nibabel as nib import imageio import cv2 def read_niifile(niifilepath): # 读取niifile文件 img = nib.load(niifilepath) # 提取niifile文件 img_fdata = img.get_fdata(dtype='float32') return img_fdata def save_fig(niifilepath, savepath, num, name): # 保存为图片 name = name.split('-')[1] filepath_seg = niifilepath + "segmentation\" + "segmentation-" + name filepath_vol = niifilepath + "volume\" + "volume-" + name savepath_seg = savepath + "segmentation\" savepath_vol = savepath + "volume\" if not os.path.exists(savepath_seg): os.makedirs(savepath_seg) if not os.path.exists(savepath_vol): os.makedirs(savepath_vol) fdata_vol = read_niifile(filepath_vol) fdata_seg = read_niifile(filepath_seg) (x, y, z) = fdata_seg.shape total = x * y for k in range(z): silce_seg = fdata_seg[:, :, k] # 三个位置表示三个不同角度的切片 if silce_seg.max() == 0: continue else: silce_seg = (silce_seg - silce_seg.min()) / (silce_seg.max() - silce_seg.min()) * 255 silce_seg = cv2.threshold(silce_seg, 1, 255, cv2.THRESH_BINARY)[1] if (np.sum(silce_seg == 255) / total) > 0.015: silce_vol = fdata_vol[:, :, k] silce_vol = (silce_vol - silce_vol.min()) / (silce_vol.max() - silce_vol.min()) * 255 imageio.imwrite(os.path.join(savepath_seg, '{}.png'.format(num)), silce_seg) imageio.imwrite(os.path.join(savepath_vol, '{}.png'.format(num)), silce_vol) num += 1 # 将切片信息保存为png格式 return num if name == 'main': path = r"C:\Users\Administrator\Desktop\LiTS2017" savepath = r"C:\Users\Administrator\Desktop\2D-LiTS2017" filenames = os.listdir(path + "segmentation") num = 0 for filename in filenames: num = save_fig(path, savepath, num, filename) 替换掉代码中的cv2模块,实现相同功能

2023-05-25 上传

import os import numpy as np import nibabel as nib import imageio import cv2 def read_niifile(niifilepath): # 读取niifile文件 img = nib.load(niifilepath) # 提取niifile文件 img_fdata = img.get_fdata(dtype='float32') return img_fdata def save_fig(niifilepath, savepath, num, name): # 保存为图片 name = name.split('-')[1] filepath_seg = niifilepath + "segmentation\\" + "segmentation-" + name filepath_vol = niifilepath + "volume\\" + "volume-" + name savepath_seg = savepath + "segmentation\\" savepath_vol = savepath + "volume\\" if not os.path.exists(savepath_seg): os.makedirs(savepath_seg) if not os.path.exists(savepath_vol): os.makedirs(savepath_vol) fdata_vol = read_niifile(filepath_vol) fdata_seg = read_niifile(filepath_seg) (x, y, z) = fdata_seg.shape total = x * y for k in range(z): silce_seg = fdata_seg[:, :, k] # 三个位置表示三个不同角度的切片 if silce_seg.max() == 0: continue else: silce_seg = (silce_seg - silce_seg.min()) / (silce_seg.max() - silce_seg.min()) * 255 silce_seg = cv2.threshold(silce_seg, 1, 255, cv2.THRESH_BINARY)[1] if (np.sum(silce_seg == 255) / total) > 0.015: silce_vol = fdata_vol[:, :, k] silce_vol = (silce_vol - silce_vol.min()) / (silce_vol.max() - silce_vol.min()) * 255 imageio.imwrite(os.path.join(savepath_seg, '{}.png'.format(num)), silce_seg) imageio.imwrite(os.path.join(savepath_vol, '{}.png'.format(num)), silce_vol) num += 1 # 将切片信息保存为png格式 return num if __name__ == '__main__': path = r"C:\Users\Administrator\Desktop\LiTS2017" savepath = r"C:\Users\Administrator\Desktop\2D-LiTS2017" filenames = os.listdir(path + "segmentation") num = 0 for filename in filenames: num = save_fig(path, savepath, num, filename)替换掉代码中的cv2模块,实现相同功能

2023-05-25 上传