doubt regards the program for the regionprops
Info
This question is closed. Reopen it to edit or answer.
Show older comments
sir I done these following steps
function area()
originalImage = imread('result.png');
binaryImage = originalImage<140;
labeledImage = bwlabel(binaryImage, 8);
D=regionprops(labeledImage,'all');
end
i need to save all regionprops values like area, perimeter,etc... to the database how its been done and what is procedure for save all that values in database
Answers (2)
Image Analyst
on 21 Nov 2012
save(matFileName, D);
2 Comments
ajith
on 21 Nov 2012
Image Analyst
on 21 Nov 2012
Oh, I forgot. For some reason, save() wants the variables enclosed in single quotes, so they're strings with the name of the variable rather than the variable itself. I don't know why - it shouldn't be necessary in my opinion - but, for whatever reason, that's the way they do it. So just do this:
save(matFileName, 'D');
Walter Roberson
on 21 Nov 2012
save('result.mat', D) %result.mat will be your database, with a single set of data in it.
22 Comments
Walter Roberson
on 21 Nov 2012
save('data.mat', 'D')
ajith
on 22 Nov 2012
Walter Roberson
on 22 Nov 2012
There is a database toolbox. I do not know if there is another way. I guess it could be done via ActiveX on MS Windows systems.
First you will need to define what your database keys are : if you are storing for multiple images, then how do you wish to be able to refer to a specific result later?
ajith
on 22 Nov 2012
Walter Roberson
on 22 Nov 2012
You are only going to store the regionprops information for a single image into any one database? That sounds like pretty high overhead.
Are you already retrieving the images from an MS Access database, and you wish to process each image and write back the regionprops for each image into the record associated with that image? If so then showing your existing code to retrieve an image would help.
ajith
on 22 Nov 2012
Image Analyst
on 22 Nov 2012
And he answered that question by referring you to the Database Toolbox or to write it yourself with ActiveX. He's not going to write a toolbox for you or write an ActiveX function for you. There are ActiveX examples out there so you can do that yourself if you cannot afford the toolbox. But it's not something someone could bang out in just a few minutes so that's why we can't do it for you.
Walter Roberson
on 22 Nov 2012
Please clarify: is the database to store information for one image, or for multiple images? If it is for multiple images, then what information do you wish to add in to the database in order for you to be able to retrieve the regionprops information for any particular image ?
ajith
on 23 Nov 2012
Walter Roberson
on 23 Nov 2012
Do you have the Database Toolbox?
Suppose that you did manage to store all of the information in an MS Access database. Suppose you now wish to retrieve the information for one particular image. What unique information about the image would you provide to retrieve the information about that image? For example, will you know that it is image #17 and would want to supply the 17 to retrieve the information? Or would you want to provide the filename that the image was stored in to do the retrieval? Or is there a "title" of some sort for each image and you would search on the title?
ajith
on 23 Nov 2012
Walter Roberson
on 23 Nov 2012
You wrote above that "i need to store the regionprops data to MS access. but actually i retrieve the images from the folder only"
That implies that you are not saving the image to the MS Access database, just the regionprops data for the image.
When you say "are stored in the order of the database", do you mean that your database index field will be a sequence number that you will allow MS Access to fill in automatically? And you will be fine with the possibility that MS Access might happen to store the information for (say) the 17th image between (say) the information for the 5th and 6th image? And that the information for the first image you insert might end up as (say) the 9th database entry?
Have you ever used a database before? Are you familiar with the idea of database search keys or index fields? Can you show us a sample SQL query that you would use to retrieve the information for a particular image?
Do you have the Database Toolbox?
Image Analyst
on 23 Nov 2012
Once it's in the database (I assume data for all images will be in the same .mdb file), then what will you do? Are you going to use Access and open up the database and do stuff with Access? Or are you still going to want to read the database and do stuff in MATLAB? If you're going to use MATLAB, and not use Access, then save it as a .mat file, not as an .mdb file. If you just want to do queries, such as "show me all images with an area fraction greater than 5%" then you can do that kind of thing in MATLAB you know.
Walter Roberson
on 23 Nov 2012
If you do not have the database toolbox, then there is no tutorial. You will need to use activex() to activate a COM object instance of MS Access and use whatever methods MS Access provides, which is determined entirely by MS Access.
I would suggest that you go over to MS Access documentation on microsoft.com and read about how to use MS Access until you understand the basics of indexing (as a concept) and understand how to create a database schema.
ajith
on 26 Nov 2012
Image Analyst
on 26 Nov 2012
I have not done this so I can't help you. Again, are you sure it MUST be an Access .mdb file you must use and you can't do it with MATLAB .mat file?
ajith
on 26 Nov 2012
Walter Roberson
on 26 Nov 2012
Normally you would use an SQL type statement in the database toolbox to store the values. But you do not have the database toolbox, so you are going to have to learn MS Access's ActiveX API and do the storing using those calls. That is not something I have had reason to do, myself, and I do not wish to volunteer to investigate it.
What is it that you plan to do with the data once you have it in a database?
ajith
on 26 Nov 2012
Image Analyst
on 26 Nov 2012
You didn't answer his question: "What is it that you plan to do with the data once you have it in a database?" Plus, there is always example code that comes with toolboxes that explains how to do it. Have you gone through all the examples yet? They should teach you.
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!