can i use more than one hold on function in same code?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am dividing an image in four quadrants recursively if they satisfy the condition. For that I am using following code:
figure;
imshow(lf);
div_rec_A(lf,rf,r,c,g1_squ,g2_squ);
function div_rec_A( lf,rf,r,c,g1_squ,g2_squ )
hold on;
xv1=[c/2,c/2];
yv1=[1,r];
line(xv1,yv1,'Color','r','LineWidth',1);
xh1=[1,c];
yh1=[c/2,c/2];
line(xh1,yh1,'Color','r','LineWidth',1);
if condition
%copy the part in another image
else
lf = AL;
rf = AR;
[r c] = size(lf);
g1_squ = AFL;
g2_squ = AFR;
div_rec_A(lf,rf,r,c,g1_squ,g2_squ);
here lf and rf are two images, r and c are dimension of the image and g1_squ and g2_squ are gradient of the lf and rf respectively. AL and RL is image portion of first quadrant of lf and rf images respectively. And AFL and AFR is image portion of first quadrant of g1_squ and g2_squ images respectively.
The above code works well and divides the first quadrant of the image but now I want to divide image of all four quadrants. So I made other three same functions namely div_rec_B(lf,rf,r,c,g1_squ,g2_squ), div_rec_C(lf,rf,r,c,g1_squ,g2_squ), div_rec_D(lf,rf,r,c,g1_squ,g2_squ) because the conditions are different for each quadrant. And all four functions are called in main function sequentially.
The problem is, the division of only first function is displayed. I tried adding
figure;
imshow(lf);
in each function at starting. It shows the result but I want all the divisions to be done on single image. So I guess the hold on function is not holding the image after first function. I didn’t write hold off in any of the function.
I hope the problem is clear. Plz HELP. Thanks in advance.
4 comentarios
Adam
el 3 de Mzo. de 2015
View -> Plot Browser on your figure will show you a list of all objects plotted on your axes.
Respuestas (1)
Ingrid
el 3 de Mzo. de 2015
the question is not completly clear (it helps if you would use the code lay-out option so that is better parsed), but it does not seem to make sense to use the hold on option in this case since you only have one image it seems and thus only one axes...
did you try stepping trhough your code to make sure that xv1 and yv1 are calculated correctly for the other quadrants. It could be that the offset is ill-defined causing the lines to be drawn, but not visible to you because outside of visible range.
3 comentarios
Adam
el 3 de Mzo. de 2015
That looks more like a bug in your recursion than a problem with the axes 'hold' status. If the hold status were switched off at any point you would lose the original image which would be a big clue.
Also if that is the first quadrant you calculate rather than the last that also suggests there is not a problem with the hold status.
Ver también
Categorías
Más información sobre Graphics Object Properties en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

