I read set of images and I removed the borders of them, I need to save the resulted images in a new folder but i couldnt. I used this code but I didnt get a result, I need a help, plz?
1 view (last 30 days)
srcFiles = dir('C:\Users\..\ImagesWithBorder\*.tif'); % the folder in which our images exists
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\..\ImagesWithBorder\',srcFiles(i).name);
I = imread(filename);
% figure, imshow(I);
J = rgb2gray(I);
for row = 1 : r
for col = 1 : c
if J(row,col) >= 90
J(row,col) = 0;
Finalfilename = sprintf('C:\\Users\\ahmadjalal2013\\Desktop\\Thesis_Images\\ImagesWithoutBorder\\%02d',i);
imwrite ( J, 'Finalfilename', 'tif');
Image Analyst on 15 Jan 2017
Edited: Image Analyst on 15 Jan 2017
You shouldn't have single quotes around the filename when you pass it into imwrite(). Here, use this code instead:
outputFolder = 'C:/Users/ahmadjalal2013/Desktop/Thesis_Images/ImagesWithoutBorder';
baseFileName = sprintf('%02d.tif', i);
fullFileName = fullfile(outputFolder, baseFileName); % Prepend folder.
Note that there is a .tif extension in the baseFileName so you do not need to pass it into imwrite(). Also note that forward slashes work just fine with Windows in path names.
More Answers (1)
John BG on 15 Jan 2017
this code does what you want
as example let's start with this image
2. Selecting 2 diagonal points that define the borders you want to remove. I use command ginput but you already have the values
3. Calculating border values from ginput points
4. Removing on borders, one side of the frame at a time
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, if you find this answer of any help please click on the thumbs-up vote link,
thanks in advance for time and attention