How to return multiple image as output results by the for-loop of the function into the mainDifferent function returns from command line and within functionHow can I index a MATLAB array returned by a function without first assigning it to a local variable?Manipulations within sliding window functions (for image denoising)Finding the common segments of two noncontinuous vectorsGroup matrix values into separate matrices based on values of another matrixcordinate of intersection pixel of 2 line segments in a chess-board“Out of Memory” MatlabHandwritten Word Segmentation using neural networkImage segmentation algorithm in MATLABArea under log curves in Octave, array of coordinate points from image of line
What is my malfunctioning AI harvesting from humans?
In reversi, can you overwrite two chips in one move?
Why are Gatwick's runways too close together?
Look mom! I made my own (Base 10) numeral system!
Can a one way NS Ticket be used as an OV-Chipkaart for P+R Parking in Amsterdam?
Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?
A stranger from Norway wants to have money delivered to me
Is this cheap "air conditioner" able to cool a room?
Generator for parity?
Ex-contractor published company source code and secrets online
Author changing name
How do I explain to a team that the project they will work on for six months will certainly be cancelled?
Accidentals - some in brackets, some not
Team goes to lunch frequently, I do intermittent fasting but still want to socialize
Acceptable to cut steak before searing?
Are there any financial disadvantages to living significantly "below your means"?
Are any jet engines used in combat aircraft water cooled?
Was this a rapid SCHEDULED disassembly? How was it done?
Infeasibility in mathematical optimization models
Shabbat clothing on shabbat chazon
In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?
Why isn’t SHA-3 in wider use?
Who are these characters/superheroes in the posters from Chris's room in Family Guy?
Ordering a word list
How to return multiple image as output results by the for-loop of the function into the main
Different function returns from command line and within functionHow can I index a MATLAB array returned by a function without first assigning it to a local variable?Manipulations within sliding window functions (for image denoising)Finding the common segments of two noncontinuous vectorsGroup matrix values into separate matrices based on values of another matrixcordinate of intersection pixel of 2 line segments in a chess-board“Out of Memory” MatlabHandwritten Word Segmentation using neural networkImage segmentation algorithm in MATLABArea under log curves in Octave, array of coordinate points from image of line
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to get all the segmented lines image results from my functions into the main, but it only returns the last line of the input image.
Here is the function for line segmentation code:
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
while kap<((q/2)+1)%number of loops=number of lines
k=1;
mat5=([]);
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Here is the main code:
close all;
clear all;
clc;
img=imread('num_ip.tif');
img2=charextract(img);
imshow(img2);
matlab
add a comment |
I want to get all the segmented lines image results from my functions into the main, but it only returns the last line of the input image.
Here is the function for line segmentation code:
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
while kap<((q/2)+1)%number of loops=number of lines
k=1;
mat5=([]);
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Here is the main code:
close all;
clear all;
clc;
img=imread('num_ip.tif');
img2=charextract(img);
imshow(img2);
matlab
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15
add a comment |
I want to get all the segmented lines image results from my functions into the main, but it only returns the last line of the input image.
Here is the function for line segmentation code:
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
while kap<((q/2)+1)%number of loops=number of lines
k=1;
mat5=([]);
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Here is the main code:
close all;
clear all;
clc;
img=imread('num_ip.tif');
img2=charextract(img);
imshow(img2);
matlab
I want to get all the segmented lines image results from my functions into the main, but it only returns the last line of the input image.
Here is the function for line segmentation code:
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
while kap<((q/2)+1)%number of loops=number of lines
k=1;
mat5=([]);
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Here is the main code:
close all;
clear all;
clc;
img=imread('num_ip.tif');
img2=charextract(img);
imshow(img2);
matlab
matlab
asked Mar 27 at 7:44
KHUMANKHUMAN
115 bronze badges
115 bronze badges
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15
add a comment |
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15
add a comment |
1 Answer
1
active
oldest
votes
The problem is that you are clearing the mat5 container every time the while loop runs. If you move it out of the while loop, it should fix the problem.
Edit: The K is also being set to 1 every time the while loop runs. This means after the first iteration of the for loop. K will equal 1 k=1
and will overwrite your previous data.
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
mat5=([]); % moved out of while loop
k=1;
while kap<((q/2)+1)%number of loops=number of lines
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372083%2fhow-to-return-multiple-image-as-output-results-by-the-for-loop-of-the-function-i%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that you are clearing the mat5 container every time the while loop runs. If you move it out of the while loop, it should fix the problem.
Edit: The K is also being set to 1 every time the while loop runs. This means after the first iteration of the for loop. K will equal 1 k=1
and will overwrite your previous data.
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
mat5=([]); % moved out of while loop
k=1;
while kap<((q/2)+1)%number of loops=number of lines
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
add a comment |
The problem is that you are clearing the mat5 container every time the while loop runs. If you move it out of the while loop, it should fix the problem.
Edit: The K is also being set to 1 every time the while loop runs. This means after the first iteration of the for loop. K will equal 1 k=1
and will overwrite your previous data.
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
mat5=([]); % moved out of while loop
k=1;
while kap<((q/2)+1)%number of loops=number of lines
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
add a comment |
The problem is that you are clearing the mat5 container every time the while loop runs. If you move it out of the while loop, it should fix the problem.
Edit: The K is also being set to 1 every time the while loop runs. This means after the first iteration of the for loop. K will equal 1 k=1
and will overwrite your previous data.
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
mat5=([]); % moved out of while loop
k=1;
while kap<((q/2)+1)%number of loops=number of lines
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
The problem is that you are clearing the mat5 container every time the while loop runs. If you move it out of the while loop, it should fix the problem.
Edit: The K is also being set to 1 every time the while loop runs. This means after the first iteration of the for loop. K will equal 1 k=1
and will overwrite your previous data.
function mat5 = charextract(ipimg)
%%%aa=imread('num_ip.tif');
bb=rgb2gray(ipimg);
cc=imbinarize(bb);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% SEGMENTATION %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[x,y]=size(cc);
ee=sum(cc,2);
mat2=y-ee;
mat3=mat2~=0;
mat4=diff(mat3);
index1=find(mat4);
[q,w]=size(index1);%size of index2 matrix is q*w
kap=1;
lam=1;
mat5=([]); % moved out of while loop
k=1;
while kap<((q/2)+1)%number of loops=number of lines
for j=(index1(lam)+1):1:index1(lam+1)
mat5(k,:)=cc(j,:); %store the line segmented matrix
%aaddj=mat5(k,:);
k=k+1;
end
lam=lam+2;
kap=kap+1;
%aa=mat5+1;
%figure, imshow(mat5);
end
end
edited Mar 27 at 8:32
answered Mar 27 at 8:10
Hojo.TimberwolfHojo.Timberwolf
5594 silver badges18 bronze badges
5594 silver badges18 bronze badges
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
add a comment |
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
Still, I got the last line of the input image.
– KHUMAN
Mar 27 at 8:23
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
After moving out the K, it gives the same input image as output without any segmentation of the lines.
– KHUMAN
Mar 27 at 9:49
still not getting. need help
– KHUMAN
Apr 1 at 14:22
still not getting. need help
– KHUMAN
Apr 1 at 14:22
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372083%2fhow-to-return-multiple-image-as-output-results-by-the-for-loop-of-the-function-i%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If your still having trouble, please paste a sample image into the question and lets see how we can get the program to function correctly
– Hojo.Timberwolf
Mar 28 at 5:15