【脑切片图像分割】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. 输出结果

脑切片图像分割结果

相关推荐
kaixin_啊啊1 天前
Micam 多容器太吃资源?用 Go2RTC + EasyNVR 给小米摄像头换一套轻量本地录像方案
图像处理·人工智能·摄像头
weixin_307779132 天前
C++代码实现MATLAB中的ode23tb函数功能
开发语言·c++·算法·matlab
PixelBai2 天前
SVG 文件如何打开、预览与压缩?前端图标优化的一条龙做法
图像处理
菜鸟~noob2332 天前
【太空电子战】从CCS到Meadowlands:反通信系统的二十年演进史【含matlab代码】
开发语言·matlab
szxinmai主板定制专家2 天前
NXP LS1046A 硬件方案: LS1046A+FPGA 异构加速架构实践
大数据·图像处理·人工智能·嵌入式硬件·fpga开发
sali-tec3 天前
C# 基于OpenCv的视觉工作流-章108-区域筛选
图像处理·人工智能·opencv·算法·计算机视觉
菜鸟~noob2333 天前
【太空电子战】Meadowlands作战验收:美国太空军可逆干扰能力的里程碑【含matlab代码】
matlab·电子战
岁月蹉跎的一杯酒3 天前
ISPDiffuser:用扩散模型学习 RAW→sRGB 映射
图像处理·isp
刘广睿3 天前
影栈实战:AI 生图放大不再糊,Hires.fix 与 ESRGAN 超分从 512 到 4K 封面
图像处理·人工智能·深度学习·aigc·效率工具
菜鸟~noob2334 天前
【Bonjour】华为Peerium架构深度解析:从冯·诺依曼到百万处理器“一台计算机”,附MATLAB性能仿真【含matlab代码,可直接运行】
开发语言·matlab·华为·peerium