Read the corresponding image in matlab

조회 수: 1 (최근 30일)
annmaria
annmaria 2015년 7월 24일
댓글: annmaria 2015년 7월 26일
I calculated the distance between an image A1 and different images like image1,image2,image3 and image4 based on its hierarchicalCentroid. dist_1_1{ii} contains 4 values. I want to find the minimum value present in the dist_1_1{ii}.But I shows the value 1 and also i want to show the image which gives minimum value. Please help me. Thanks in advance
%%demo
clc,clear all,close all
plotFlag = 1;
depth = 6;
alef1 = im2bw(imread('C1.bmp')); %%Binary image
vec1 = hierarchicalCentroid(alef1,depth,plotFlag);
% subplot(1,3,1);
A=[];
vec2=[];
dist_1_1=[];
for ii=1:4
A{ii} = imread(['image' num2str(ii) '.bmp']);
% subplot(1,3,2);
vec2{ii} = hierarchicalCentroid(A{ii},depth,plotFlag);
%subplot(1,3,3);
%vec3 = hierarchicalCentroid(tav,depth,plotFlag);
% vec4=hierarchicalCentroid(A,depth,plotFlag);
% vec5=hierarchicalCentroid(A,depth,plotFlag);
dist_1_1{ii} = sum((vec1 - vec2{ii}) .^ 2);
[~,I] = min(dist_1_1{ii});
figure;
subplot(1,2,1);imshow(alef1);
subplot(1,2,2);imshow(A{I});
end
  댓글 수: 7
Walter Roberson
Walter Roberson 2015년 7월 25일
[~,I] = min(dist_1_1{ii});
imshow(A{I})
annmaria
annmaria 2015년 7월 26일
thank you sir Its working

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 7월 24일
You have a variable "m" that tells you which is the image with the minimum distance, but you have not indicated anything about how "m" corresponds to a file name. Are the file names sequential such as img1.tif img2.tif img3.tif ... img9.tif img10.tif img11.tif ? Did you use dir() to find the names of the images and you still have the result of dir() stored?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by