Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
I have a bunch of images I would like analyzed for a specific "shape_feature". I would prefer not to have to point to each one individually. I would like to write a little program (in Mathcad) that points to a directory, does the image processing and gets the "shape_feature" I want and then goes to the next image in the directory. I think I know how to do this except I don't know how to have Mathcad point to a directory and look at all the files in the directory. Any help would be appreciated.
Solved! Go to Solution.
Hi Marcus.
With Mathcad 15 you can write a vbscript component. But I guess that is more easy to use a DOS command window with "dir *.jpg > names.txt", read "names.txt" into mathcad and use the string functions inside mathcad to recover the names.
Best regards.
Alvaro.
Hi Marcus.
With Mathcad 15 you can write a vbscript component. But I guess that is more easy to use a DOS command window with "dir *.jpg > names.txt", read "names.txt" into mathcad and use the string functions inside mathcad to recover the names.
Best regards.
Alvaro.
Thanks Alvaro for the insight,
I am using Mathcad Prime 3.1 and ideally I was hoping to keep everything in Mathcad but your suggestions may be workable for me. Thanks for the suggestion.
Does anyone else have a potentially more direct suggestion? Something that stays in Mathcad?
You cannot write VBscript components in Prime, that feature is only available in the real Mathcad (version 15 and earlier)..
Also in the real mathcad is an undocumented function Files(), that allows two parameters, the first is a directory name (string), the second is an optional file type qualifier, directly linked to the 'attributes' of a file, such as R (read-only), H (hidden), D(directory) etc.
I don't know if that works in Prime.
At first sight: no
Also appears like there's a realer Mathcad: version11 knows the Files() function, Mathcad version 15 lost it.
Success!
Luc
Then there is the other opion of writing your own function (in C) in a DLL. However so far returning an array of strings from a user defined DLL function is not supported, but you could fill a matrix with ascii values (one file name per column, pad with zero's) and use the vec2str() function to convert each column of the matrix to a file name.
Now hope they've already implemented vec2str() in Prime...Yes, they did!
Luc
Hey Guys,
So I appreciate both your help and I think I am very close to getting what I need. I ended up just using the DOS command window as I am not very savvy with C.
Ideally, what I want is to be able to point my Mathcad sheet to a directory full of images, it gives me the area of those images and compiles the different areas into a matrix. I am very close to having this working but I have a programing error. My program "Area" (in the worksheet) works as long as it only iterates once. For example, if you change "while P does not equal NaN" to "while n<2" the program works. I want the program to go through the list of files, getting the areas until "P equals NaN". Can you see what is wrong with my program? It is probably a silly error. Thanks.
To compare a variable to NaN, you have to use the function IsNaN() -- you cannot compare directly. In your case, you'll obviously need to use the logical "not" comparison as well.
I did not check your program for any other errors.
Thanks everyone. I was able to get the Mathcad sheet working properly. I appreciate the help.