WebREAD returns zeors when reading a GIF image

1 回表示 (過去 30 日間)
Xiaogang Liu
Xiaogang Liu 2022 年 3 月 8 日
コメント済み: Xiaogang Liu 2022 年 3 月 8 日
I am using an Online server from NIH to convert a SMILES string to a GIF image.
This SMILES string defines a chemical structure, which is dipicted in the GIF picture.
For example, by defining the URL as https://cactus.nci.nih.gov/chemical/structure/O=c1oc2ccccc2cc1-c1cn2ccccc2n1/image this server generates a picture.
However, when I read the image using WebRead, I only get an array (250*250) of zeros .
testURL='https://cactus.nci.nih.gov/chemical/structure/O=c1oc2ccccc2cc1-c1cn2ccccc2n1/image';
myData=webread(testURL);
Does anyone know what is going wrong in this case?
How should we modify the code to retrieve the image?
Many thanks.

採用された回答

Steve Eddins
Steve Eddins 2022 年 3 月 8 日
I got an array of zeros once using your code, but later I ran it again and got the expected image data. I quit MATLAB and launched a new session, and I got the expected image data on the first (and all subsequent) attempts.
I'm not sure, but I suspect that a server issue is causing it to sometimes send all zeros.
Also, I recommend that you use two output arguments in your call to webread. GIF files use colormaps, and you need to get the colormap to display the image correctly, like this:
testURL='https://cactus.nci.nih.gov/chemical/structure/O=c1oc2ccccc2cc1-c1cn2ccccc2n1/image';
[myData,map]=webread(testURL);
imshow(myData,map)
  1 件のコメント
Xiaogang Liu
Xiaogang Liu 2022 年 3 月 8 日
Dear Steve,
Many thanks for the suggestion and the great help.
I switched to another computer (on the way home). It is working now!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by