• 忽然发现，以前对这段matlab理解有误： lambda = [10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;... 10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;... 10^(-5), 0.5*10^(-4), 1
忽然发现，以前对这段matlab理解有误：

lambda = [10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;...
10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;...
10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;...
10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;...
10^(-5), 0.5*10^(-4), 10^(-4), 0.5*10^(-3), 10^(-2), 0.5;];

 mask = [ 0     0     0     0     0     1
0     1     0     0     0     0
0     1     0     0     0     0
0     0     0     0     0     1
0     0     0     0     1     0];
我以前以为：

lambda(logical(mask)) = [0.5
0.5e-4
0.5e-4
0.5
0.01];但真正的情况是：

lambda(logical(mask)) = [0.5e-4
0.5e-4
0.01
0.5
0.5];
这个和matlab的存储方式有关，自己需时刻谨记啊


展开全文
• clc;clear; data=imread('DR_ck_0001.tiff'); img = double(data); eps=0.04; log_img = log_trans(img);...img_basic = gradient_guidedfilter(log_img, log_img, eps);...img_detail = log_img-img_basic;...
1.对原图进行log变换
2.利用导向滤波提取基层、细节层
3.限制亮度最大值、最小值
clc;clear;
img = double(data);
eps=0.04;
log_img = log_trans(img);
img_detail = log_img-img_basic;
tmp = log(2 + (img_basic./max(img_basic(:))).^0.2345*8);
img_basic_compress= log(img_basic+1)/log10(max(img_basic(:)+1))./tmp;
img_basic_compress = img_basic_compress.^(1/2.2);
img_detail_enhanced = 2.*atan(20*img_detail)/pi;
img_enhanced = img_basic_compress + img_detail_enhanced;
cut_max = min(img_enhanced(:)) + 0.97 * (max(img_enhanced(:)) - min(img_enhanced(:)));
cut_min = min(img_enhanced(:)) + 0.01 * (max(img_enhanced(:)) - min(img_enhanced(:)));
img_enhanced(find(img_enhanced>cut_max)) = cut_max;
img_enhanced(find(img_enhanced<cut_min)) = cut_min;
img_enhanced = (img_enhanced - cut_min) ./ (cut_max - cut_min);
img_enhanced = medfilt2(img_enhanced, [3,3]);
img_enhanced = uint8(img_enhanced*255);
subplot(2,3,1);imshow(data,[]);title('原图');
subplot(2,3,2);imshow(log_img,[]);title('log');
subplot(2,3,3);imshow(img_basic_compress,[]);title('基础层');
subplot(2,3,4);imshow(img_detail_enhanced,[]);title('细节层');
subplot(2,3,5);imshow(img_enhanced,[]);title('结果');
imwrite(uint8(img_enhanced),'zhongbe.png');
subplot(2,3,6);imhist(data,256);title('直方图');
function out = log_trans(img)
%INPUT: img double
log_img = log(img + exp(-10));
log_min = log(min(img(:))+exp(-10));
log_max = log(max(img(:))+exp(-10));
out = (log_img - log_min)/(log_max - log_min);
end
%主程序
function q = gradient_guidedfilter(I, p, eps)
%   GUIDEDFILTER   O(1) time implementation of guided filter.
%
%   - guidance image: I (should be a gray-scale/single channel image)
%   - filtering input image: p (should be a gray-scale/single channel image)
%   - regularization parameter: eps

r=16;
[hei, wid] = size(I);
N = boxfilter(ones(hei, wid), r); % the size of each local patch; N=(2r+1)^2 except for boundary pixels.

mean_I = boxfilter(I, r) ./ N;
mean_p = boxfilter(p, r) ./ N;
mean_Ip = boxfilter(I.*p, r) ./ N;
cov_Ip = mean_Ip - mean_I .* mean_p; % this is the covariance of (I, p) in each local patch.

mean_II = boxfilter(I.*I, r) ./ N;
var_I = mean_II - mean_I .* mean_I;

%weight
epsilon=(0.001*(max(p(:))-min(p(:))))^2;
r1=1;

N1 = boxfilter(ones(hei, wid), r1); % the size of each local patch; N=(2r+1)^2 except for boundary pixels.
mean_I1 = boxfilter(I, r1) ./ N1;
mean_II1 = boxfilter(I.*I, r1) ./ N1;
var_I1 = mean_II1 - mean_I1 .* mean_I1;

chi_I=sqrt(abs(var_I1.*var_I));
weight=(chi_I+epsilon)/(mean(chi_I(:))+epsilon);

gamma = (4/(mean(chi_I(:))-min(chi_I(:))))*(chi_I-mean(chi_I(:)));
gamma = 1 - 1./(1 + exp(gamma));

%result
a = (cov_Ip + (eps./weight).*gamma) ./ (var_I + (eps./weight));
b = mean_p - a .* mean_I;

mean_a = boxfilter(a, r) ./ N;
mean_b = boxfilter(b, r) ./ N;

q = mean_a .* I + mean_b;
end
%子程序boxfilter()

function imDst = boxfilter(imSrc, r)

%   BOXFILTER   O(1) time box filtering using cumulative sum
%
%   - Definition imDst(x, y)=sum(sum(imSrc(x-r:x+r,y-r:y+r)));
%   - Running time independent of r;
%   - Equivalent to the function: colfilt(imSrc, [2*r+1, 2*r+1], ‘sliding‘, @sum);
%   - But much faster.

[hei, wid] = size(imSrc);
imDst = zeros(size(imSrc));

%cumulative sum over Y axis
imCum = cumsum(imSrc, 1);
%difference over Y axis
imDst(1:r+1, :) = imCum(1+r:2*r+1, :);
imDst(r+2:hei-r, :) = imCum(2*r+2:hei, :) - imCum(1:hei-2*r-1, :);
imDst(hei-r+1:hei, :) = repmat(imCum(hei, :), [r, 1]) - imCum(hei-2*r:hei-r-1, :);

%cumulative sum over X axis
imCum = cumsum(imDst, 2);
%difference over X axis
imDst(:, 1:r+1) = imCum(:, 1+r:2*r+1);
imDst(:, r+2:wid-r) = imCum(:, 2*r+2:wid) - imCum(:, 1:wid-2*r-1);
imDst(:, wid-r+1:wid) = repmat(imCum(:, wid), [1, r]) - imCum(:, wid-2*r:wid-r-1);
end



展开全文
• 比如以图像中某点为中心，取到中心距离<n的点集 for循环来计算距离比较耗时 x = 1:rows; //rows为图像行数 y = 1:cols; //cols为图像列数 [xx,yy] = meshgrid(y,x); dist = (yy-row).^2 + (xx-col).^2;...
比如以图像中某点为中心，取到中心距离<n的点集
for循环来计算距离比较耗时
  x = 1:rows;  //rows为图像行数
y = 1:cols;  //cols为图像列数
[xx,yy] = meshgrid(y,x);
dist = (yy-row).^2 + (xx-col).^2; //(row, col)为指定为中心点
dist = sqrt(dist);
inds = find(dist < n);  //到中心点距离< n个像素的index(按列扫描顺序)



展开全文
• I = imread('family.jpg'); [H,W,~] = size(I); gray = rgb2gray(I); subplot(2, 2, 1); imshow(I, []); title('Original Image');...binaryImage = hFH.createMask();...title('Binary mask of the region'...
I = imread('family.jpg');
[H,W,~] = size(I);
gray = rgb2gray(I);
subplot(2, 2, 1);
imshow(I, []);
title('Original Image');
hFH = drawfreehand();

subplot(2, 2, 2);
imshow(binaryImage);


展开全文
• 进制位数可以自己设置，码元速率可以自己设置，载波频率可以自己设置，亲自有用
• 在计算地球物理参数，如温度、降水等的区域平均时，通常要面积加权，该代码用于生成全球各种分辨率格点的面积。
• 它是 Matlab poly2mask 函数的一种补充。 不同之处在于返回所有轮廓点 - 没有丢失线性相关点的点。 为了获得 poly2mask 的 100% 互补，应省略直线内的所有点。 就我而言，我实际上需要所有这些点，作为投资回报率的...
• grayImage = imread('monkey.png'); % Read in standard MATLAB gray scale image.  subplot(2, 2, 1);  imshow(grayImage, []); title('Original Grayscale Image');  hFH = imfreehand(); %Choos
• 用于组合线性和逻辑索引的 MATLAB 助手

千次阅读 热门讨论 2020-03-30 15:27:53
wfu_pickatlas（简直神器） 直接在主页面打开，就是酱紫： 选择Human atlas后，点击aal(AAL是一个脑区模板)，就会出来所有脑区的名称，比如我想要脑岛的模板，就点击nsula_R和insula_L : 点击save mask就完成了。...

...