imcrop function problem for 16bit image 2019b

Dear all,
The following imcrop code gives an error in 2019b
I = imread('XX.tif');
[Icrop, rect] = imcrop(I, [ ]);
It seems that 2019b does't support [ ] with imcrop. If you are working with 16 bit images then you will be in trouble because you need to see the image before croping it, and for that you need to put the [ ].
Any idea how to overcome this problem?
Thank you in advance.
Meshoo

6 commentaires

Which of the syntaxes is that intended to be? Is it an empty colormap, or is it an empty rect specification ?
Meshooo
Meshooo le 20 Sep 2019
The image, I , used in I = imread('XX.tif') is a gray image of uint16.
I have the same problem, could you figure out how to fix it?
What is it that you intend the [] to mean to imcrop? The function has two possible arguments at that point: colormap or rect specification. Which one do you intend by the []?
Meshooo
Meshooo le 11 Oct 2019
Modifié(e) : Meshooo le 11 Oct 2019
Hi Walter,
I couldn't understand exactly what do you mean. I am just runing my old codes in 2019 and got an error.
People working with uint16 images usually use [ ] to show the image on their screens, for example: imshow(I_unit16, [ ]).
Similarly, we need to use [ ] when croping uint16 image in order to dispaly the image before cropping it. That was possible in older versions of MATLAB but not in 2019b.
Regards,
Meshoo
Please name a particular release that documents using [] as a parameter to imcrop() . I looked through the archived documentation for several releases and could not find any evidence that it was ever a supported option.
Similarly, we need to use [ ] when croping uint16 image in order to dispaly the image before cropping it.
So display the image with imshow() with the documented [] option, and call imcrop() on the handle returned by imshow:
h = imshow(I, []);
[Icrop, rect] = imcrop(h);

Connectez-vous pour commenter.

 Réponse acceptée

h = imshow(I, []);
[Icrop, rect] = imcrop(h);

9 commentaires

Meshooo
Meshooo le 16 Oct 2019
OK, thank you very much. Although I wish if things can be run without modifing my code, because it was used alot.
I do not find any evidence that the effect was ever documented.
You can create an Enhancement Request with Mathworks asking for the syntax to be restored.
You could create your own imcrop that is earlier on the sort order than Mathwork's imcrop . Invoking Mathwork's imcrop from that would be a bit of a nuisance.
Meshooo
Meshooo le 17 Oct 2019
Thank you for your suggestion. Acctully I coppied the imcrop function from older version of MATLAB and replaced it in the image processing library of 2019b and it was working well. However, the problem still there if you compile your code with 2019b Compiler for other users.
Well then I suggest you open a bug report and ask for a fix.
So just take out the [] before you compile. What's the big deal? You're probably going to make a few other changes anyway, and there is a lot more involved in recompiling and deploying a new version than just hitting the delete key 3 times. Since it's such an insignificant amount of work to find all calls to imcrop and delete the brackets I suggest you just do it. It's a lot less work than submitting a bug report.
Replace calls to imcrop with calls to my_imcrop that looks for the [] case and makes the appropriate adjustment.
Meshooo
Meshooo le 18 Oct 2019
Modifié(e) : Meshooo le 18 Oct 2019
Thanks for your suggestions, Image Analyst and Walter. I think bug report would be a better choice. Although it is a very simple problem, but I think many other poeple will face the same problem, and already the user Sahar Tavakoli faced the same problem and commented to this post.
I am not familiar with making bug reports, if anyone would like to do it then very appreciate it.
regards,
Meshoo
Then you'll be making a lot of bug reports. There is a constant flow of functions either changing inputs, being deprecated, or being removed completely as versions progress through the years. I don't see how that, either filing bug reports or writing a custom wrapper and calling that from your code, is any better than just hitting the delete key 3 times.
Meshooo
Meshooo le 18 Oct 2019
For me it's already solved and thanks for the many help I got from all of you. For many other users it is still an issue.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by