How can I create a 1*1struct data, which has two fields?
Mostrar comentarios más antiguos
I want to create a mat file, which contains 1*1 struct data with two fields. One is "label" and another is "train". Label containst a 320*320 image and train contains "320*320" random lines.
A sample is given below .
12 comentarios
Gulfam Saju
el 9 de Mayo de 2022
dpb
el 9 de Mayo de 2022
So, what's the issue, precisely?
S.label=yourimagearray;
S.train=rand(320);
save 'YourNewMatFileName' S
Gulfam Saju
el 9 de Mayo de 2022
dpb
el 9 de Mayo de 2022
What I gave you will let you do exactly that if the field variable train will contain an image array suitable for imshow
What you Q? said was you wanted a random variable there.
Still don't see the problem. What have you done to try to solve it and where did you have a problem?
Gulfam Saju
el 9 de Mayo de 2022
Editada: Gulfam Saju
el 9 de Mayo de 2022
dpb
el 9 de Mayo de 2022
That's very inconvenient at the moment owing to other real work/data loaded in my workspace I don't want to mess with...attach the image as an image (use the image icon left of the paper clip). I've found saving fig as .jpg works nicely here...
Gulfam Saju
el 9 de Mayo de 2022
Editada: Jan
el 9 de Mayo de 2022
dpb
el 9 de Mayo de 2022
Then
- Select the number of coordinates in x direction
- Compute a spacing for those based on whatever is the underlying distribution desired -- looks something like inverse 1/x kind of thing, maybe.
- Given those positions, set the density of the speckles for each line
- Generate the positions to set -- nchoosek might be useful here as one way to generate the random permutation of vertical coordinates
Jan
el 9 de Mayo de 2022
@Gulfam Saju: I've edited your comment such that the image is displayed as image directly. This is more convenient than posting a link.
Your image is huge: 3840x1940 pixels. It is hard to guess, what exactly do you want in your 320x320 image based on this example. Does the large white border matter? The description "train contains "320*320" random lines" is far to vague to be answered seriously.
Gulfam Saju
el 9 de Mayo de 2022
Jan
el 9 de Mayo de 2022
@Gulfam Saju: Okay, I'vwe removed the white border for you also. It would be smart, if you do such work by your own. The less the readers have to do, the more time they have to provide a useful answer. So it is a good idea to provide the details such, that answering is as easy as possible.
The posted image has a structure and is not random. Look on the round artifacts in the corners. Does this matter?
Respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
