I have a satellite image in the BSQ format. I initially processed it using ENVI. Now, I am trying to read the image using Matlab's multibandread function.
This is the data pertaining to the image I am trying to load
samples = 911
lines = 3191
bands = 196
header offset = 0
data type = 2
interleave = bsq
byte order = 0
This is the code I've written to load the image.
I = multibandread('QUAC.bsq',[3191,911,196], ...
'int16','0','bsq','ieee-le',{'Band','Direct',[29,23,16]});
I am getting the following errors:
Error using multibandread>parseInputs (line 311)
Unable to open QUAC.bsq for reading.
Error in multibandread (line 112)
info = parseInputs(filename, dims,...
I looked up the format for the multibandread function on this website
http://www.ehu.es/ccwintco/uploads/d/dc/LoadHypercubesMatlab.pdf
I checked the code for parseInputs on MATLAB, but I was unable to make any difference.
What mistake am I committing while trying to load the image?
The question is a bit old, but it may be useful for somebody else to know the answer.
This was most likely a wrong filename ('QUAC.bsq'), or that file was not located in the current MATLAB working directory.
There is another mistake in the list of arguments that, with a valid filename, returns this error in Matlab 2015b :
Error using multibandread>parseInputs (line 337)
Expected input to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64
Instead its type was char.
Error in multibandread (line 111)
info = parseInputs(filename, dims,...
Replacing '0' with 0 in multibandread arguments should fix the problem, worked for me. The correct syntax is:
I = multibandread('QUAC.bsq',[3191,911,196], ...
'int16',0,'bsq','ieee-le',{'Band','Direct',[29,23,16]});
Related
I read a 'lable.png' file with unit8 format using 'imread' in Matlab and cv.imread in OpneCV, but the result is different.
In specific, the result of cv.imread is correct, but the result of 'imread' in Matlab converts the actual 255 to 0, which is wrong.
Here is the code:
matlab:
map = imread('label.png')
python:
map = cv2.imread('label.png')
I want to know why it happens and how to read the right value using Matlab?
If I read in a png image with imread in matlab, my values range from 0 to 255 (black is 0 in all channels). Maybe in your case, the function is inferring the format of your content wrong. Try stating the format directly:
m = imread('image.png', 'png');
Finally, the problem is solved by:
map=imread('image.png','BackgroundColor','none')
Hi I'm trying to fit a power model to my data using MatLab's fit function
fo = fit(log2(x(:)),log2(y(:)),'power1');
plot(fo,'g'), hold on
However when I run this I get the error
Error using fit>iFit (line 282)
Cannot fit Power functions to data where X has nonpositive values.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in CurvedPowerLaw (line 20)
fo = fit(log2(x(:)),log2(y(:)),'power1');
When looking at my data and checking if any are less than 1, nothing is displayed
x(count_1)=M(i,1);
y(count_1)=M(i,2);
count_1= count_1+1;
if(M(i,2)<1)
display(M(i,1))
end;
M is a csv file with two columns. I also re ran the code for
if(M(i,1)<1)
and nothing was displayed. Checking manually and nothing seemed to be below 1 either.
i is just the line in the file that is being parsed. The file looks like
344,17
345,13
346,13
347,16
340,12
M(i,1) will result in returning one of the >300 numbers and M(i,2) will return ~10 value
Any help would be much appreciated!!
Thanks
While all values that were parsed in were >0 when scaling them by log2 that's where the 0 values started appearing. A quick fix was to add 1 to each value when parsing them in.
I have downloaded a btf file (big tiff) from the links below, how can I read it and "imshow" it? is there a way to convert it to tiff format as the btf is not that common?
Link:
https://drive.google.com/file/d/0ByhuP_NuuARtSW9aeTdPUTlRdWM/view?usp=drive_web
http://www.photomacrography.net/forum/viewtopic.php?t=28990&sid=cca737a2e0bc7ea3e2e41f0d6e75f5a9
I used this code:
t = Tiff('d:/Image_687.btf','w8');
imageData = read(t);
and got this error:
Error using tifflib
Unable to retrieve PhotometricInterpretation.
Error in Tiff/getTag (line 838)
tagValue = tifflib('getField',obj.FileID,Tiff.TagID.(tagId));
Error in Tiff/read (line 1487)
photo = obj.getTag('Photometric');
Error in Untitled2 (line 2)
imageData = read(t);
The real issue with your code is the second parameter that you have passed to Tiff. As the documentation states, the second parameter indicates in what mode to open the file. You have specified w8 which the documentation states is:
open TIFF file for writing a BigTIFF file; discard existing contents.
This means that it is deleting your image before you even start! If you want to use the Tiff class, you'll want to either use no second parameter or the r parameter to open the file for reading.
t = Tiff('Image_687.btf');
t = Tiff('Image_687.btf', 'r');
That being said, in general it is better to try to load it with a higher level function such as imread. The Tiff class is a much lower-level function that can be a little harder to manipulate but may provide some needed specialty functionality.
im = imread('Image_687.btf');
size(im)
3072 4080 3
I had to do a little manipulation for display because the RGB values weren't between 0 and 255
im = double(im);
im = uint8(255 * im ./ max(im(:)));
imshow(im);
Why is that whenever I try to use detectSURFFeatures(img) with a binary image in matlab gives me proper points but whenever I use detectMSERFeatures(img) with the same binary image gives me error instead of pointing some valid regions?
ERROR:
Error using detectMSERFeatures
Expected input number 1, I, to be one of these types:
uint8, int16, uint16, single, double
Instead its type was logical.
Error in detectMSERFeatures>parseInputs (line 75)
validateattributes(I,{'uint8', 'int16', 'uint16', ...
Error in detectMSERFeatures (line 64)
[Iu8, params] = parseInputs(I,varargin{:});
Try this:
make image 2 double first by using img=im2double(img);
then feed it to MSER
detectMSERFeatures(img)
detectMSERFeatures does not accept logical inputs, as stated in the documentation and in the error you are receiving. detectSURFFeatures does. I don't know if there's a specific reason why, as I'm not familiar with the limitations of the different algorithms.
You could simply convert your binary image to one of the types listed, and run MSER on it:
detectMSERFeatures(double(img));
How to convert .dcm(dicom) image to .bmp format.
I have tried this, but its not working for me.
000000.dcm is a medical lung image (size 6 MB)
dcmimg = dicomread('000000.dcm');
>> imshow(dcmimg);
DCM image read in dcmimg
imwrite(dcmimg, 'myfile.bmp');
Getting error:
Error using writebmp (line 15)
Expected X to be one of these types:
logical, uint8, single, double
Instead its type was uint16.
Error in imwrite (line 477)
feval(fmt_s.write, data, map, filename, paramPairs{:});
I am not understanding these errors, What's going wrong. Help me out, Thank You.
Dicom uses unsigned 16 bit integers. The function that writes .bmp files expects a different data type, as explained by the error message. This suggests that the following should work:
imwrite(double(dcmimg), 'myFile.bmp');
By explicitly converting the data type to double you should get rid of the error. Actually single might be enough... It too can represent 16 bit integers without loss of precision.