在 matlab 中求图像的逆对数变换

发布于 2024-12-10 07:11:20 字数 202 浏览 0 评论 0原文

我几乎一整天都在寻找这个。对数变换的一般形式是

s = clog(1+r) 

其中

c = 0.1 

相反的是逆对数变换(书)。对数逆变换是什么?是

s = exp(r)吗?

无法获得正确的输出。

I have been searching for this almost all day. The general form of the log transformation is

s = clog(1+r) 

where

c = 0.1 

The opposite is inverse log transformation(book). What will be the inverse log transformation? Is it

s = exp(r)?

Could not get right output.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

朱染 2024-12-17 07:11:21

这适用于逆对数变换

clc;
clear all;
close all;
a=imread('imagename.jpg');
ad=im2double(a);
x=ad;
[r,c]=size(ad);
factor=1;
for i=1:r
    for j = 1:c
  x(i,j)= exp(ad(i,j)^factor)-1;
    end
end
subplot(1,2,1);imshow(ad);title('before');
subplot(1,2,2);imshow(x);title('after');

This works for inverse log transformation

clc;
clear all;
close all;
a=imread('imagename.jpg');
ad=im2double(a);
x=ad;
[r,c]=size(ad);
factor=1;
for i=1:r
    for j = 1:c
  x(i,j)= exp(ad(i,j)^factor)-1;
    end
end
subplot(1,2,1);imshow(ad);title('before');
subplot(1,2,2);imshow(x);title('after');
七婞 2024-12-17 07:11:21
import cv2
import numpy as np
# Open the image.
img = cv2.imread('InverseLogTransform.jpg')
cv2.imshow('Input',img)
# Apply log transform.
c = 255 / (np.log(1 + np.max(img)))
ilog_transformed = np.(exp(img/c))-1
# Specify the data type.
ilog_transformed = np.array(ilog_transformed, dtype=np.uint8) 
cv2.imshow('ILog',ilog_transformed)
cv2.waitKey(0)cv2.destroyAllWindows()
import cv2
import numpy as np
# Open the image.
img = cv2.imread('InverseLogTransform.jpg')
cv2.imshow('Input',img)
# Apply log transform.
c = 255 / (np.log(1 + np.max(img)))
ilog_transformed = np.(exp(img/c))-1
# Specify the data type.
ilog_transformed = np.array(ilog_transformed, dtype=np.uint8) 
cv2.imshow('ILog',ilog_transformed)
cv2.waitKey(0)cv2.destroyAllWindows()
南七夏 2024-12-17 07:11:20

如果 Log()自然对数。如果您的 Log() 使用不同的基数(基数 2、基数 10、任何其他任意基数),那么您将需要使用不同的基数来代替 eExp()中。

更新

尝试10^(x/0.1)-1x/0.1 撤消 0.1 * 操作,10^ 撤消 log()- 1 撤消+1

Exp() will only be an inverse of Log() if Log() is the natural logarithm. If your Log() is using a different base (base 2, base 10, any other arbitrary base), then you will need to use the different base in place of e in Exp().

Update

Try 10^(x/0.1)-1. x/0.1 undoes the 0.1 * operation, 10^ undoes the log(), and -1 undoes the +1.

七秒鱼° 2024-12-17 07:11:20

我认为您定义了 c 将结果图像标准化为有效(可见)范围。那么c 的有理值可以是:

c = (L - 1)/log(L) 

其中L 是灰度级数。因此 s 将是:

s = log(r+1) .* ((L – 1)/log(L)) 

s = log(r+1) .* c

那么反转转换将是:

s2 = (exp(r) .^ (log(L) / (L-1))) – 1

s2 = (exp(r) .^ (1/c)) – 1

这是 L=256 的转换输出:

在此处输入图像描述

应用此转换到我们需要做的图像一些类型转换:

figure;
L = 256;
I = imread('cameraman.tif');
log_I = uint8(log(double(I)+1) .* ((L - 1)/log(L)));
exp_I = uint8((exp(double(I)) .^ (log(L) / (L-1))) - 1);
subplot(2, 2, [1 2]); imshow(I); title('Input');
subplot(2, 2, 3); imshow(log_I); title('\itlog(I)');
subplot(2, 2, 4); imshow(exp_I); title('\itexp(I)');

“在此处输入图像描述"

I think you defined c to normalize the resulting image to a valid (visible) range. Then a rational value for c could be:

c = (L - 1)/log(L) 

where L is the number of gray levels. So s would be:

s = log(r+1) .* ((L – 1)/log(L)) 

or

s = log(r+1) .* c

Then the inverted transformation would be:

s2 = (exp(r) .^ (log(L) / (L-1))) – 1

or

s2 = (exp(r) .^ (1/c)) – 1

This is the transformation output for L=256:

enter image description here

To apply this transformation to an image we need to do some typecasting:

figure;
L = 256;
I = imread('cameraman.tif');
log_I = uint8(log(double(I)+1) .* ((L - 1)/log(L)));
exp_I = uint8((exp(double(I)) .^ (log(L) / (L-1))) - 1);
subplot(2, 2, [1 2]); imshow(I); title('Input');
subplot(2, 2, 3); imshow(log_I); title('\itlog(I)');
subplot(2, 2, 4); imshow(exp_I); title('\itexp(I)');

enter image description here

你的往事 2024-12-17 07:11:20

您可以使用幂律变换来执行此操作,因为在幂律变换中,您可以移动曲线以执行对数变换或执行逆对数变换,这会影响高级别像素,但不会影响低级别像素。您可以使用此

a=imread('Figure-3.tif');
a=im2double(a);
[r,c]=size(a);
gamma=0.6;
C=1;
for i=1:r
for j=1:c
   s(i,j)=C*(a(i,j)^gamma);
end
end
imshow(s);

You can use power law transform to do this as in power law transform you can shift the curve so as to perform log transform or to perform inverse log transform which effects high level pixels but not low level pixels..You may use this

a=imread('Figure-3.tif');
a=im2double(a);
[r,c]=size(a);
gamma=0.6;
C=1;
for i=1:r
for j=1:c
   s(i,j)=C*(a(i,j)^gamma);
end
end
imshow(s);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文