how do i save extracted feature vectors of an image database?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Hello everybody
i have a DB of images for a CBIR project and i have to extract different types of features (color : using HSV, texture : using LBP) which i already did, now my qs is how to save those extracted features in a dataset of features to which the CBIR system would go back to, to retreive the similar images ? .. is it a ".mat" file or some other way ? and is it possible to gather the different types of features in the same dataset knoing that their vector sizes are different too? can anyone please help
채택된 답변
Image Analyst
2021년 1월 2일
Yes, you can save your variables in a .mat file. Use the save() function, like
save('answers.mat', 'var1', 'feature2', 'something3');
or whatever. They don't all need to be the same size or even class.
댓글 수: 10
Thank you Image Analyst, so if i understand well, by saving all the features (of my DB images) in one mat file i can go back to them while retrieving the similar images only by loading the file and specifying the feature needed using a line like this for example :
DB_features = load(fullFileName);
HSV = DB_features.HSV;
i have a kind of ambiguity here can you please help me with it, while retrieving and applying a metric measure, what would be the result or the output ? i mean the metric would calculate the distance between the features of the dataset features and the query image features, how can it show images corresponding to features with the smallest distance ?
Yes, exactly. You tell save what variables you want to save. Then you use load() to recall them. All the variables you saved will be in a structure. If you want them in their own variable with names like they used to have then you can take the field and put it into a variable like you did.
If you compute the difference between an unknown image, and the features you saved for your training set, then you can do that. I don't know what metrics you want to measure. Of course they may have different units or even be unitless. For example you might store the gray level intensity, the mean and stddev of all the individual color channels, the area fraction of something, etc. So you can't just take the Euclidean distance of all of them because the area fraction will be between 0 and 1 and be unitless while the intensities have much larger ranges and have units of gray levels. So you have to figure out some weighting to apply to the various metrics to get some sort of overall similarity index.
Once you have that, you can pull out image names from your database that have similar metrics as your test image. For example like in this extremely cool, interactive CBIR website that recalls images based on colors you tell it.
I appreciate your reponse, and the CBIR website is really cool.
so to answer you, what i want to measure is the HSV and LBP feautures extracted from both the unknown/query image and the database image, i'll use for that the euclidian distance (it could be any other methode euclidian, manhatan distance or mahalanobis ..), i know i can't apply the euclidean distance (for example) on all the metrics just like that, because each would have a distinct specificity to consider (as you gave in the example of intensities and area fraction), and i kind of have the same thing in my case cuz the output feature vector for HSV and LBP are different in size (the HSV gives me a vector of 1x32, and LBP a vector of 1x3776
excuse my question, but the part of pulling out the image names that have similar metrics how does it happen knowing that the distance computing happens only between the query image feature and features of the database images (which are now no longer images with names) ? should we save the features (somehow i don't really know) with the names of images, or do those features stay related to the images and names even if they're now just features (values) stored in their own file (in this case a .mat file) ?
Well you have to store the filename along with its features. I'd recommend a structure array so the image and its features are all kept together. Like
features(k).fileName = filename;
features(k).meanH = meanH;
features(k).meanS = meanS;
features(k).meanV = meanV;
features(k).lbpVector = lbpVector;
etc. for all the features you measure. k is the index and will range from 1 to however many images you have. Then save the structure array in a .mat file:
save('My Features.mat', 'features');
Okey now i got it.
Again Thank you so much for explaning and the time you put into it, and happy new year btw.
i have one more question please, when i created the struct array as you recomanded the fileName field had the same fileName (the last image name) in all the rows, and it's size is 1x16 , it shoulb 200x16 or so. the other fields are good, they all contain features extracted from each of the images.

ps : the fileName is called baseFileName in my code.
how do i fixe that, any advice or suggestion please ?
You need to do
features(k).fileName = filename;
in your loop as I suggested. You're not putting in the index so you're doing
features.fileName = filename;
I did here's the code of it :
for k = numberOfFiles %(which are the 200 images)
features(k).baseFileName = baseFileName;
features(k).HSV_images = HSV_images;
features(k).LBP_images = LBP_images;
save('MyFeatures.mat', 'features');
end
is it possible that it has something to do with the fact that the names has both numbers and letters, ex : 'P0890_output.png' ?
Show the whole loop. You left out the parts where you get new baseFileName, HSV_Images, and LBP_Images. If baseFileName changes in the loop (as it should, along with the images), then the structure array should have different file names.
Got it fixed, it's actually silly as an issue, it was just the ':' missing in the :
k = 1:numberOfFiles
Thank you anyway
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
