clear
I = imread('C:\Users\admin\Desktop\书稿图片再加工\3.3.8.png');
figure
imshow(I);
% I = I(72:232,579:599,:);
iimag = double(reshape(I,[],3));
cmap = jet(256)*256;
cmap = [cmap;[255,255,255];[0,0,0]];
cmaphot = hot(256)*256;
cmaphot = [cmaphot;[255,255,255];[0,0,0]];
for i = 1:length(iimag)
% aa = find(cmap==squeeze(iimag(i,:)));
for ii = 1:258
aa(ii) = norm(cmap(ii,:)-squeeze(iimag(i,:)));
end
[aaa,id] = min(aa);
if isempty(aa)
indexx(i) = 258;
% elseif iimag(i,1)==iimag(i,2) && iimag(i,1)==iimag(i,3) && iimag(i,1)~=255
% indexx(i) = 258;
else
indexx(i) = id;
end
%
end
for i = 1:length(iimag)
imaghot(i,:) = cmaphot(indexx(i),:);
end
figure
Isize = size(I);
imshow(uint8(reshape(imaghot,[Isize(1),Isize(2),3])))
MATLAB 已生成图片colorbar颜色转换
最新推荐文章于 2024-08-19 11:29:09 发布