I am executing matlab script ( converted into .sh file using mcc ) using exec command from php . exec("./run_searchIMage.sh <Matlab Path> > output file 2>&1 & ") .
Show older comments
Running this command from php is giving error Error Using imshow IMSHOW unable to display image.
Code snipet where it is giving error .
f1 = figure('Visible','off'); imshow(im1_);hold on; f=figure('Visible','off'); imshow(im2_); hold on;
Accepted Answer
More Answers (1)
Walter Roberson
on 1 Jul 2013
0 votes
When you run it from PHP there is probably no DISPLAY environment variable set.
When you say "run it from PHP" do you mean by a web server? If so then the web server session is not connected to any display, and so is not able to display graphics. The most it can do in such a case is to compute an image of a graphic and send the image to the web session using an appropriate MIME type.
5 Comments
Walter Roberson
on 1 Jul 2013
Invoke matlab with the -nodisplay option.
You will not be able to use imshow().
You will be able to use plot() and other routines, and you will be able to saveas() some kinds of files. You can then return the file from PHP. For example read http://stackoverflow.com/questions/900207/return-a-php-page-as-an-image
Anirudh Goyal
on 1 Jul 2013
Walter Roberson
on 1 Jul 2013
What do you want the imshow() to do in your situation?
If your concern has to do with trying to run the same code in two different situations, then it is possible to code to detect the situation and have the imshow() not performed when there is no display. And if it is important that the code not be altered, then you can use your own routine named imshow.m that does the test and invokes the real imshow if there is a display.
If you are wanting the graphics generated by MATLAB to show up on the user's system, the you need to do like I discussed above (saveas etc). If that is not acceptable then you should be reconsidering whether you want this to be a web service, or if instead you want it to be handled by Terminal Server or Remote Desktop or VNC to provide "live" MATLAB sessions.
Anirudh Goyal
on 1 Jul 2013
Walter Roberson
on 2 Jul 2013
Try using image() or imagesc() instead of imshow()
Categories
Find more on File Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!