• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MATLAB小函数:展示灰度图像数据集的部分样例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

MATLAB小函数:展示灰度图像数据集的部分样例

作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/

更多请看:MATLAB作图

    给定一个.mat文件的灰度图像数据集,用MATLAB程序展示该图像数据集的一部分样例,每一类都展示相同数目的样例图,并将它们汇总成一幅图并保存图片。数据来源:Face databases (Yale, ORL, PIE and YaleB)

1. MATLAB程序

Image_integration.m

function Image_samples=Image_integration(data, real_label, N_samples)
% Gray image integration
% This code only applies to square matrices
% Input:
% data: dataset. N*Dim
% real_label: GroundTruth. N*1
% N_samples: number of selected samples
% Output:
% Image_samples:Integrated image
% Author: kailugaji https://www.cnblogs.com/kailugaji/
[~, Dim]=size(data);
[real_label, b]=sort(real_label);
data=data(b, :);
K=length(unique(real_label)); % number of cluster
[~, ID]=unique(real_label);
ID=ID-1;
image_10=cell(N_samples, K);
temp=cell(N_samples, K);
Image_samples=[];
for i=1:N_samples
    for j=1:K
        temp{i, j}=reshape(data(ID(j)+i, :), sqrt(Dim), sqrt(Dim)); % you can change its size
        image_10{i, j}=[image_10{i, j}, temp{i, j}];
    end
    Image_samples=[Image_samples; image_10{i, :}];
end

demo.m

clear
clc
% Author: kailugaji https://www.cnblogs.com/kailugaji/
interval=7; % The size of the middle space
N_samples=10; % number of selected samples
load(\'ORL_64x64.mat\')
Image_samples=Image_integration(fea, gnd, N_samples);
A=mat2gray(Image_samples);
figure(1)
imshow(A, \'Border\',\'tight\'); 
print(gcf,\'-r1000\',\'-djpeg\',\'My_ORL.jpg\');

load(\'Yale_64x64.mat\')
Image_samples=Image_integration(fea, gnd, N_samples);
B=mat2gray(Image_samples);
figure(1)
imshow(B, \'Border\',\'tight\'); 
print(gcf,\'-r1000\',\'-djpeg\',\'My_Yale.jpg\');

A_=imresize(A,[500, 2000]);
B_=imresize(B,[500, 750]);
C=[A_, 255.*ones(size(A_(:, 1:interval, :))), B_];
figure(3)
imshow(C, \'Border\',\'tight\'); 
print(gcf,\'-r1000\',\'-djpeg\',\'My_Image.jpg\');

2. 结果

ORL数据集部分样例图

Yale数据集部分样例图

两个数据集合并在一起的样例示意图


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap