Message Boards Message Boards

GROUPS:

Import images, use the GradientOrientationFilter and export them?

Posted 8 months ago
830 Views
|
2 Replies
|
2 Total Likes
|

I would like to import images from a folder, pass them through the GradientOrientationFilter and save the output image in another folder.

I have tried many ways but was unsuccesful at doing it. I am able to manually drag a single image apply the filter and manually save the output but i am unable to do it for the images in a folder and export them automatically to a different folder. I used the example in the documentation to manually do it

GradientOrientationFilter[img,4]// ImageAdjust

Can someone please help me on how to write a loop to perform the above operation.

Thanks

2 Replies

There are many ways you can do that.

Here is one:

pathToFiles = "/yourPath/..";
SetDirectory[pathToFiles];
newPath = FileNameJoin[{pathToFiles, "newPath"}];
If[!DirectoryQ[newPath],
	CreateDirectory[newPath];
];
files = FileNames["*.jpg", pathToFiles];
Export[FileNameJoin[{newPath, FileNameTake[#, -1]}], ImageAdjust[GradientOrientationFilter[Import[#], 4]]] & /@ files
Posted 8 months ago

Thank you

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract