LIME 低亮度图像增强的offical code
时间: 2024-06-09 21:06:33 浏览: 10
LIME(Low-Light Image Enhancement via Illumination Map Estimation)是一种基于深度学习的低光图像增强方法,它利用亮度估计图生成更明亮、更清晰的图像。LIME的官方代码目前还没有发布,但是有一些相似的方法可以作为参考。
以下是一些公开代码,可以用来实现低亮度图像增强:
1. RetinexNet: https://github.com/weichen582/RetinexNet
2. DCP: https://github.com/csjunxu/DCP
3. MIRNet: https://github.com/swz30/MIRNet
4. DeepUPE: https://github.com/wangruixing/DeepUPE
这些代码都是基于深度学习的方法,可以用于低亮度图像增强。其中,RetinexNet和DCP是经典的Retinex算法的深度学习实现;MIRNet和DeepUPE是最近提出的一些高质量的低光图像增强方法。您可以根据您的需要选择其中的一个进行尝试。
相关问题
LIME 低亮度图像增强的offical demo code
LIME(Low-Light Image Enhancement via Illumination Map Estimation)的官方demo代码可以在GitHub上找到:https://github.com/zccyman/LIME。
该demo代码使用Python语言和PyTorch深度学习框架实现了LIME算法,并提供了预训练的模型和测试图像,以供用户进行测试和实验。
具体使用方法如下:
1.克隆或下载代码库
2.安装PyTorch和其他必要的依赖项
3.下载预训练模型和测试图像
4.运行demo代码,输出增强后的图像
以下是示例代码的使用示例:
```
# import necessary modules
import torch
import numpy as np
from PIL import Image
from LIME import LIME
# load the pre-trained model
model = LIME()
model.load_state_dict(torch.load('model.pth', map_location='cpu'))
# load the test image
img = Image.open('test.png')
# convert the image to tensor and normalize it
img_tensor = torch.from_numpy(np.array(img)).float().permute(2, 0, 1)
img_tensor = img_tensor / 255.0
# enhance the image
enhanced_img_tensor = model(img_tensor.unsqueeze(0)).squeeze(0)
# convert the tensor to image
enhanced_img = Image.fromarray((enhanced_img_tensor.permute(1, 2, 0) * 255.0).numpy().astype(np.uint8))
# show the enhanced image
enhanced_img.show()
```
在运行上述代码之前,请确保已经在代码目录中下载了预训练模型和测试图像,并将它们放在正确的文件夹中。
LIME 低亮度图像增强的offical demo code matlab
以下是 LIME 低亮度图像增强的官方演示代码,使用 MATLAB 编写:
```matlab
clear all;
close all;
clc;
% Read the input image
inImg = imread('sample.jpg');
inImg = im2double(inImg);
figure, imshow(inImg), title('Input Image');
% Compute the dark channel prior
patchSize = 15;
darkChannel = getDarkChannel(inImg, patchSize);
% Estimate the atmospheric light
atmLight = getAtmLight(inImg, darkChannel);
% Recover the transmission
transmission = getTransmissionEstimate(inImg, atmLight, patchSize);
% Perform the image dehazing
dehazedImg = performDehazing(inImg, transmission, atmLight);
% Display the output image
figure, imshow(dehazedImg), title('Dehazed Image');
% Get the dark channel prior
function darkChannel = getDarkChannel(img, patchSize)
[h, w, ~] = size(img);
darkChannel = zeros(h, w);
paddedImg = padarray(img, [floor(patchSize/2), floor(patchSize/2)], Inf);
for i = 1:h
for j = 1:w
patch = paddedImg(i:i+patchSize-1, j:j+patchSize-1, :);
darkChannel(i, j) = min(patch(:));
end
end
end
% Get the atmospheric light
function atmLight = getAtmLight(img, darkChannel)
[h, w, ~] = size(img);
imgSize = h * w;
numPixels = round(imgSize * 0.1);
[~, indices] = sort(darkChannel(:), 'descend');
indices = indices(1:numPixels);
maxVals = max(img,[],3);
atmLight = zeros(1,3);
for i = 1:numPixels
[row, col] = ind2sub([h w], indices(i));
atmLight = max(atmLight, squeeze(img(row, col, :)));
end
end
% Get the transmission estimate
function transmission = getTransmissionEstimate(img, atmLight, patchSize)
img = im2double(img);
[h, w, ~] = size(img);
transmission = zeros(h, w);
imgGray = min(img,[],3);
A = repmat(atmLight, h, w);
for i = 1:h
for j = 1:w
patch = imgGray(max(1,i-floor(patchSize/2)):min(i+floor(patchSize/2),h), ...
max(1,j-floor(patchSize/2)):min(j+floor(patchSize/2),w));
transmission(i,j) = 1 - 0.95*min(patch(:))/A(i,j);
end
end
end
% Perform the image dehazing
function dehazedImg = performDehazing(img, transmission, atmLight)
img = im2double(img);
[h, w, ~] = size(img);
A = repmat(atmLight, h, w);
transmission = max(transmission, 0.1);
dehazedImg = zeros(size(img));
for i = 1:3
I = img(:,:,i);
J = (I - A(i))./transmission + A(i);
dehazedImg(:,:,i) = J;
end
end
```
使用时,将输入图像的文件名替换为您自己的图像文件名即可。请注意,此代码只能用于 MATLAB。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)