Problems in converting raster to vector in QGIS3 - qgis

I am trying to convert some raster layers (from a wms) to vector layers, by using the Polygonize tool in QGIS3.14, however I always get this decoding error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 41: invalid start byte
I even tried some other sample rasters but the same errormessage was given.
Is there any suggestion of what I can do to solve this problem?
I hope that somebody can help me

Related

Unknown encoding in a EEG text file (matlab)

I am working with an epilepsy EEG dataset (https://archive.physionet.org/pn6/chbmit/). In this dataset, there is a small text file (appendix .edf.seizures) that denote start and end time (e.g. [2951 3030] maybe they are integers but I am not sure) of seizure.
I am having trouble reading this file into matlab. Using the following code:
file = '/{filename}.edf.seizures';
fscanf(fopen(file,'r'),'c');
I get following output:
' Xü## time resolution: 256 ìÿÿÿÿ ì ³ ì > '
I tried all other encoding types other than 'c' but they gave empty strings. Can anyone help me get the right encoding to read the file? Any ideas are appreciated. Thanks.

It appears imageLabeler cannot handle a transformed datastore?

The Matlab app imageLabeler is supposed to support the following format:
imageLabeler(imgStore)
I have an imgStore, defined as follows:
imds = imageDatastore(cellArrayOfImageFilenames);
imgStore = transform(imds, #(x)demosaic(x,'rggb'));
I have to do this, because my images are stored as bayer encoded images, and this is the only way I've figured out to get the imgStore to return these images as 3 channel RGB images. However, when I try and initalize imageLabeler, I get this error:
>> imageLabeler(imgStore)
Error using imageLabelerInternal
Expected input name to be one of these types:
char
Instead its type was matlab.io.datastore.TransformedDatastore.
Error in vision.internal.imageLabeler.imageLabelerInternal
Error in imageLabeler (line 58)
vision.internal.imageLabeler.imageLabelerInternal(varargin{:});
TLDR:
How do I get imageLabeler to handle my bayer encoded images?
The way to fix this, is with the imageDatastore 'ReadFcn' parameter. The documentation for imageDatastore explicity tells you to NOT do this, as it slows down Neural Network stuff. Here's the Matlab doc text:
Using ReadFcn to transform or pre-process 2-D images is not
recommended. For file formats recognized by imformats, specifying
ReadFcn slows down the performance of imageDatastore. For more
efficient ways to transform and pre-process images, see Preprocess
Images for Deep Learning (Deep Learning Toolbox).
So, all that said, here's the workaround:
imgStore = imageDatastore(cellArrayOfImageFilenames ...
, 'ReadFcn', #(x)demosaic(imread(x),'rggb')));

Error: The compressed pixel data is missing item delimiters.?

I am working with few Dicom files and when i try to use dicomread('filename.dcm') in MATLAB it gives the following error:
Error using dicomread>processOffsetTable (line 943)
The compressed pixel data is missing item delimiters.
Error in dicomread>processEncapsulatedPixels (line 858)
[offsetTable, offset] = processOffsetTable(metadata);
Error in dicomread>newDicomread (line 232)
X = processEncapsulatedPixels(metadata, frames);
Error in dicomread (line 86)
[X, map, alpha, overlays] = newDicomread(msgname, frames, useVRHeuristic);
I can view this same file in dicom viewing Softwares like onis, di com viewer, Sante Dicom etc.., but when i use dicomread I cannot see see them and get this error
I have so many images of this same format and cannot start from the beginning again, Is there any way I can use this file and view it.
Refer this online help.
It is common in DICOM world that not all data sets fully comply with DICOM. Most applications (you mentioned in your question) handle the non-compliant part with assumptions and workarounds based on experience and imagination.
Try setting TF to false to read these files.
Also note the list of supported transfer syntax:
Little-endian, implicit VR, uncompressed
Little-endian, explicit VR, uncompressed
Big-endian, explicit VR, uncompressed
JPEG (lossy or lossless)
JPEG2000 (lossy or lossless)
Run-length Encoding (RLE)
GE implicit VR, LE with uncompressed BE pixels (1.2.840.113619.5.2)
Check your input image is compressed with one of the above.

Using Matlab to read binary data from file

I'm currently trying to read data from a .surf file using Matlab. (I realise there will probably be quite a lot of other questions similar to this, but each is specific to its own problem, and I wasn't able to find a duplicate of what I'm about to ask; if someone else does and marks this as duplicate... apologies!)
This is what the readme for the data files says:
All of the files consist of 1-byte values, except for the
surface (surf) files, which consist of 4-byte floating-point
values. The 1-byte phase values denote the phase scaled and
quantized to the range 0-255. The 1-byte correlation and
mask values denote the weights 0-1 scaled and quantized to
the range 0-255.
I have been able to read a .phase file without any problems using
fn = 'spiral.257x257.phase';
f = fopen(fn);
fin = fread(f, [257, 257], 'uint8');
fclose(f);
However, I'm unable to read the surf file. I have tried single, float32 and real*4, the three options under 'Floating-point numbers' in the Matlab documentation for fread, as well as uint, uint32, int, int32 and long, which are the other options for 4-byte data. None of these give the correct solution at all - not even just the wrong scaling; they're completely off.
I'm pretty stuck for ideas; any advice (including general advice) would be most appreciated.

Matlab convert DCM to BMP

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.