Message Boards Message Boards


Import images, use the GradientOrientationFilter and export them?

Posted 9 months ago
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.


2 Replies

There are many ways you can do that.

Here is one:

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

Thank you

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

Group Abstract Group Abstract