How to define, edit and delete ROI in a (scatter) plot?

6 vues (au cours des 30 derniers jours)
Csaba
Csaba le 6 Avr 2016
Commenté : Csaba le 14 Avr 2016
I have a plot of data of some measurement. I want to define several ROIs in the plot, in order to make fitting, or determine the baseline or whatever reason, and I need these ROIs in a variable (or variables). Is it possible to make it grafically? All the methods I tried (imline, brush, datacursor) are for different task and does not allow editing, deleting the ROIs both from the picture and from the variable, I was not able to follow the changes I have made when tried i.e. change the limits of the ROI.
I think there should be something but I could not find it. It is so essential when someone wants to evaluate the data.
Thanks for any suggestions.
Csaba

Réponses (2)

Debarati Banerjee
Debarati Banerjee le 12 Avr 2016
For the function 'imline', you can use the method 'delete' to delete the the ROI object from figure. You may edit the position of the ROI using the method 'setPosition'.
Please refer to the section 'Methods' of the following link for more details: http://in.mathworks.com/help/images/ref/imline.html
For your case, you may find the function ' imfreehand ' helpful as well.
Hope this helps!
Cheers, Debarati
  1 commentaire
Csaba
Csaba le 12 Avr 2016
Thank you for your answer.
I tried imline and it does not work properly at least for me. There are several problems.
Just one of them: If someone deletes the line by mouse right click there is no way (or at least I did not found) to follow which "imline" was deleted. There is no "addDeleteCallback" function, and how to determine which handle was deleted, and was it really deleted?
Second: If someone modifies the position of the whole or just one of the endpoints by mouse, there is no way to identify (or at least I did not found) which imline was modified. There is an "addNewPositionCallback" function but the function it calls does not have the handle to the imline in question. The Help says:
"Whenever the ROI object changes its position, each function in the list is called with the syntax:
fcn(pos)
where pos is of the form returned by the object's getPosition method."
So no handle information is given to the function. I have several ROIs on the same plot, so it would be essential to know which ROI was modified.
I have found several other drawbacks using imline so I gave up. If you can solve these problems please tell me how. I am not a really educated Matlab user.
Yours,
Csaba

Connectez-vous pour commenter.


Debarati Banerjee
Debarati Banerjee le 13 Avr 2016
You may use the 'DeleteFcn' property to call a function when an 'imfill' object is being deleted.
>> set(h,'DeleteFcn',{@fcn}) % where h is an imfill object
In the 'fcn' function you can pass aapropriate display commands which will display messages in Command Window and help you in understanding which object is deleted/ position is changed.
  3 commentaires
Debarati Banerjee
Debarati Banerjee le 14 Avr 2016
Hello Csaba,
Please find the scripts 'mainfcn.m' and 'test.m'. In the mainfcn script I have created a ROI (h) and have added the DeleteFcn callback with the function test. Once the ROI is deleted, the test function is executed. In the test script, I am displaying a message in Command Window. Additionally I am setting the value of h to 0 for understanding purpose.
Its just an idea and I hope this helps!
Cheers Debarati
Csaba
Csaba le 14 Avr 2016
Thank for your answers, they really help me a lot! I also made my homework and found that with set it is possible to do a lot of things I did not even know before.
I am almost done, however your test.m does not give me what I need.
I tried to modify it a bit and found that the third parameter of the test.m which was ~-ed in your file contains the real handle to the imline. So getPosition(parameter3) gives me back the positions of the imline to be deleted. So far so good.
I have several question though, the answer of which I could not find in the help. Please help me in this.
Can you tell me what are the other two (or maybe more???) parameters in test.m and what can I do with them? The first parameter is a 1x1 Group (I do not know what does this mean), the second parameter says that it is a 1x1 EventData, It says that event is a deletion and also contains a 1x1 Group.
I suppose that a similar method can be used for the new position of the imline. It is important for me because I want to handle the case when the endpoints are changed also. Can you also help me in that?
Thank you for your kindness, I really appreciate it!
Csaba

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by