function retinex_btn_Callback(hObject, eventdata, handles) if ~isfield(handles, 'img') msgbox('请先选择图像!', 'error'); return end im = handles.img; im_retinex = retinex(im); axes(handles.axes2); imshow(im_retinex); [pathname, filename, ext] = fileparts(s); imwrite(im_retinex, [pathname, filesep, 'retinex_', filename, ext]); handles.im_retinex = im_retinex; guidata(hObject, handles); function im_retinex = retinex(im) im_log = log(double(im) + 1); im_mean = mean2(im_log); im_retinex = exp(im_log - im_mean); 上面的代码运行之后增强后的部分反而比原来图像更不清晰了怎么修改,给出步骤和完整代码
时间: 2024-02-13 11:02:58 浏览: 28
增强后的部分反而比原来图像更不清晰可能是因为Retinex算法增强的效果不好,可以尝试使用其他的图像增强算法。
完整代码如下所示:
```
function retinex_btn_Callback(hObject, eventdata, handles)
if ~isfield(handles, 'img')
msgbox('请先选择图像!', 'error');
return
end
im = handles.img;
im_retinex = retinex(im);
im_enhanced = imadjust(im_retinex); % 对增强后的图像进行对比度调整
axes(handles.axes2);
imshow(im_enhanced);
[pathname, filename, ext] = fileparts(handles.file);
imwrite(im_enhanced, [pathname, filesep, 'retinex_', filename, ext]);
handles.im_retinex = im_enhanced;
guidata(hObject, handles);
function im_retinex = retinex(im)
im_log = log(double(im) + 1);
im_mean = mean2(im_log);
im_retinex = exp(im_log - im_mean);
```
其中,使用了imadjust函数对增强后的图像进行对比度调整。如果仍然存在图像不清晰问题,可以尝试调整imadjust函数的输入参数,或者使用其他的图像增强算法。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.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)