【脑切片图像分割】MATLAB 图像处理 源码

1. 简单图像处理

加载图像 Brain.jpg,使用直方图和颜色分割成区域这些区域有不同的颜色。 这是一个更高级的问题,有多个解决它的方法。

例如,您可以计算具有特定数字的图像的直方图(例如 16 - 32),找到直方图中最小值的位置(参见,例如,islocalmin)并对最小值之间的强度区域应用不同的颜色。这可以通过将强度值作为颜色查找表的索引来完成(例如 hsv 生成)并将强度值重新映射到此类(请参阅 ind2rgb)。 您可以还可以通过灰度强度来缩放颜色的强度。

2. MATLAB 源码

matlab 复制代码
% Load and show image
im = imread('brain.jpg');
im = rgb2gray(im);
figure(1);
clf;
subplot(1,3,1);
imshow(im);

% Histogram
bins = 24;
subplot(1,3,2);
[counts,idx] = imhist(im,bins);
plot(idx,counts);
axis tight;
% Find minima and make sure they are integers
minima = round(idx(islocalmin(counts))');
xline(minima);

% Color regions by mapping greyscale to colormap indices
colors = hsv(numel(minima)+1); % HSV colormap for base-color for region (over hue values only)
cc = 1;
p = 0;
map = zeros(256,3);
for l = [minima, 256] % cover index (intensity) ranges from p to l, including the last one to 256
  cidx = (p+1):l;
  for k = cidx % Loop for simplicity (instead of matrix operation)
    %map(k,:) = colors(cc,:);         % No scaling w.r.t original itensity
    %map(k,:) = colors(cc,:) * k/256; % Linearly scale color value w.r.t. original intensity
    map(k,:) = colors(cc,:) * (0.25 + (k-p-1)/(l-p-1)*0.75); % Different color itensity scaling
  end
  p = l;
  cc = cc + 1;
end
imc = ind2rgb(im,map);
subplot(1,3,3);
imshow(imc);

% Show ranges in histogram by overlaying colors (could be integrated in above loop)
subplot(1,3,2);
y1 = 0;
y2 = max(counts);
cc = 1;
p = 0;
for l = [minima,256]
  h = rectangle('Position', [p, 0, l-p, y2], ...
                'FaceColor', [colors(cc,:),0.3], ...
                'EdgeColor', [colors(cc,:),0.3]);
  p = l;
  cc = cc + 1;
end

3. 输出结果

脑切片图像分割结果

相关推荐
ι:5 小时前
单相桥式全控整流仿真从零复现教学
windows·学习·matlab·simulink
菜鸟~noob2338 小时前
【电子战】第14篇:TOA 定位——圆交汇与到达时间【含matlab代码】
开发语言·matlab
简简单单做算法11 小时前
基于灰狼算法和贝叶斯联合优化的BiLSTM(GWO-BO-BiLSTM)一维时间序列预测算法matlab仿真
matlab·一维时间序列预测·gwo-bo-bilstm
FLJwu14 小时前
传感器与图像 ISP 实战 03:运动相机图像量产一致性|批次色差、白平衡漂移、整机标定与出厂图像质检方案|20 年源头工厂量产经验
图像处理·经验分享·数码相机·相机·isp
Evand J1 天前
【MATLAB例程|图像滤波降噪13】局部噪声方差自适应滤波(LNR)图像降噪与效果展示。附完整例程的下载链接
图像处理·计算机视觉·matlab·滤波·代码·降噪
Zentceh1 天前
0.001Lux是什么概念
图像处理·人工智能·科技·计算机视觉·车载系统·无人机·智能硬件
weixin_307779131 天前
C++代码实现MATLAB中的ode23t函数功能
开发语言·c++·算法·matlab
Evand J2 天前
【MATLAB例程】二维Astar路径规划与AOA-TDOA定位仿真。完整代码,附下载链接。包运行成功,带中文注释
开发语言·matlab·路径规划·代码·定位·融合定位
PixelBai2 天前
图片格式转换与 Base64 编码:JPG/PNG/WebP 选型与前端场景
图像处理
路径规划6662 天前
(MATLAB代码)退火PSO融合DWA算法的船舶路径规划MATLAB实现(260915)
matlab·路径规划·船舶·dwa·pso粒子群算法