Message Boards Message Boards

0
|
5397 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Import images, use the GradientOrientationFilter and export them?

Posted 6 years ago

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

POSTED BY: Pushkar D
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 BY: Mikayel Egibyan
Posted 6 years ago

Thank you

POSTED BY: Pushkar D
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