Effacer les filtres
Effacer les filtres

Simulink - RGB to HSV block issue (V values seemingly corrupted)

3 vues (au cours des 30 derniers jours)
Will
Will le 11 Mar 2018
Modifié(e) : DGM le 9 Nov 2022
Hello!
I have MATLAB version 2017a, and I am using Simulink to do some video processing via a Raspberry Pi and a Raspberry Pi camera. I wanted to convert a video stream from RGB to HSV, and then threshold a particular range of HSV values to filter in only one color. I have accomplished this via a script, but I wanted to reproduce it in Simulink. Below is a picture of the piece of model in question:
And the results of this via the video viewers look like this (I cannot run all three screen due to this error: "Not enough memory on the target to process the packet: EXT_SELECT_SIGNALS"):
(H and S Screens):
(V value - just a white screen...):
For some reason, the V value is broken. It only outputs all 1's. Could anybody explain this problem? The RGB image works just fine, and so do the H and S values as seen.
Please answer ASAP! The solution to this problem is time sensitive.
  2 commentaires
Will
Will le 12 Mar 2018
I have done some more debugging, and I am certain the block is bugged. It would be nice if someone could confirm. What I have done is captured a image from the RPi camera, and used it in a simple model shown below:
This model, starting from the left, takes the constant image of dimensions 240x320x3 (where the 3 dimensions represent R, G, and B), converts it into type double (so it is compatible with the "Color Space Conversion" block), feeds into the RGB to HSV block, and the output is 240x320x3 matrix, where the 3 dimensions represent H, S, and V. The selector block then selects one of the H, S, and V matrices. When I selected the H and S matricies, it produced the expected outputs, as shown below:
However, the last image shows the V matrix:
The matrix is completely filled with 1's, or rather, 255's. However, this shouldn't be so I believe. Again, if someone could confirm, I would appreciate it.
Will
Will le 12 Mar 2018
Update:
I have tested the above comment's model on another laptop with MATLAB 2015a. The block works as expected. Possible bug in 2017a release?

Connectez-vous pour commenter.

Réponse acceptée

Stefano Arrigoni
Stefano Arrigoni le 9 Nov 2022
hello,
i verified that V matrix is in the range 0-255 so if you place a gain with 1/255 at the output of V and before video viewer it works properly (in Matlab 2022a at least)
Stefano
  1 commentaire
DGM
DGM le 9 Nov 2022
Modifié(e) : DGM le 9 Nov 2022
If you feed an improperly-scaled image to the underlying conversion, it will return an improperly-scaled V, since V is just max(inpict,[],3). Casting a uint8 image as 'double' doesn't rescale it to the range expected for a floating-point image ([0 1]).
So yes, you're correct. You could rescale either before or after conversion, but in practice, I think it would be appropriate to rescale immediately after casting. Unless you're careful about how each thing handles improperly-scaled images, you run the risk of having unexpected problems like this.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Raspberry Pi Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by